Reputation: 1440
i want to write head tag.
i need create dynamic
<head id="htmlHead" runat="server">
</head>
code behind:
htmlHead.InnerText = "<script src=\"Scripts/jquery.ui.datepicker.js\" type=\"text/javascript\"></script>"
not work pls help
Upvotes: 1
Views: 128
Reputation: 61599
The head tag is a server control, so you do one of two things:
Literal scriptLiteral = new Literal();
scriptLiteral.Text = "<script src=\"Scripts/jquery.ui.datepicker.js\" type=\"text/javascript\"></script>";
Header.Controls.Add(scriptLiteral);
Or the MUCH preferred:
ClientScript.RegisterClientScriptInclude("JQuery-DatePicker", "~/Scripts/jquery.ui.datepicker.js");
Upvotes: 4