3

Consider this snippet:

<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]—>

I have access to the Page object. So I can do something like this:

Page.Header.Controls.Add(new HtmlGenericControl())

How am I able to insert the above snippet to the ASP.NET Page's Header or Body?

2 Answers 2

3

This seems hacky and there's probably a nicer solution, but this seems to work:

protected void Page_Load(object sender, EventArgs e)
{
    Literal comment = new Literal();
    comment.Text = @"<!--[if lt IE 9]><script src='//html5shiv.googlecode.com/svn/trunk/html5.js'></script><![endif]-->";
    Page.Header.Controls.Add(comment);
}
Sign up to request clarification or add additional context in comments.

Comments

-1

you can use page.clientscript.add("pageload",'')

1 Comment

The ClientScriptManager has no Method called "Add"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.