javascript - Add multiple js files on runtime in asp.net c# -
I want to add a multiple .js file to my ASP.NET c # page at run time.
Larrel Link 2 = New Lightral (); Verbal link 3 = new verbal (); Verbal link 4 = new verbal (); Link2.Text = "& lt; script src = \" Theme1 / js / jquery-1.8.2.min.js \ "type = \" text / javascript \ "/ & gt;"; Link3.Text = "& lt; script src = \" Theme1 / js / supersized.3.2.7.min.js \ "type = \" text / javascript \ "/ & gt;"; Link4.Text = "& lt; script src = \" Theme1 / js / supersized-init.js \ "type = \" text / javascript \ "/ & gt;"; Base.Page.Header.Controls.Add (link2); Base.Page.Header.Controls.Add (link3); Base.Page.Header.Controls.Add (link4); The best way to register a startup script is to:
Example:
string jsBlock = "& lt; script src = 'myJsFile.js' & gt; & lt; / script & gt; "; If (! Page.ClientScript.IsStartupScriptRegistered ("myJsInclude")) Page.ClientScript.RegisterStartupScript (typeof (string), "myJsInclude", jsBlock, incorrect);
and
/ P>
If the client script ("myJsInclude") is included in the ClientScript.RegisterClientScriptInclude ("myJsInclude", "myJsFile.js");
Comments
Post a Comment