简体   繁体   中英

Asp.net Head Problem

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

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");

尝试

htmlHead.InnerHtml

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM