Chicharito
Chicharito

Reputation: 1440

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

Upvotes: 1

Views: 128

Answers (2)

griZZZly8
griZZZly8

Reputation: 694

Try

htmlHead.InnerHtml

Upvotes: 0

Matthew Abbott
Matthew Abbott

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

Related Questions