/ Published in: C#
Place javascrip refernce or complete javascript code in page header from ascx or aspx file.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// add reference like this script1.Attributes.Add("type", "text/javascript"); script1.Attributes.Add("src", "../js/prototype.js"); this.Page.Header.Controls.Add(script1); // add full script like this // first create string which contains your javascript string YahooScript = ""; YahooScript = "\n" + "YAHOO.util.Event.onContentReady(\"izbornik\", function () {\n" + "var oMenuBar = new YAHOO.widget.MenuBar(\"izbornik\", {autosubmenudisplay: true, hidedelay: 750, lazyload: true });\n" + "oMenuBar.render();\n" + "});\n"; // and then place javascript in header script3.Attributes.Add("type", "text/javascript"); script3.InnerHtml = YahooScript; this.Page.Header.Controls.Add(script3); // in aspx page you can add script using Literal control // place Literal control in page Header in code view. // create your script string string temaSkripta = ""; temaSkripta = "\n" + "function kojaTema()\n" + "{" + "var tema = '" + tema + "';\n" + "return tema;" + "}"; // find Literal in heder and make your string it's text. Literal L = (Literal)Header.FindControl("Literal1"); L.Text = temaSkripta;