Page ClientScript RegisterStartupScript not working with meta http-equiv="X-UA-Compatible" content="IE=9"

956 Views Asked by At

I have a asp.net code which adds js to a button on runtime ...the following command does not executes properly when I change the meta http-equv content

CS code:

protected void btnPrev_Click(object sender, EventArgs e)
   {
Page.ClientScript.RegisterStartupScript(Type.GetType("System.String"), "addScript", "checkAns();", true);
}

Masterpage Code:

<meta http-equiv="X-UA-Compatible" content="IE=9" />

but it works with

<meta http-equiv="X-UA-Compatible" content="IE=8" />

And then the css rolls back to IE8 compatibility which is ugly. Please share an alternative to the problem.

1

There are 1 best solutions below

3
On

First of all don't use postback if all that you want is run javascript code, it's not efficient by any means to post the whole document to server and back to client just to do something you could have done fully on the client side in the first place. Just do html-button for example:

<button onclick="checkAns();">Do something</button>

Secondly, find out why the script is not working. That meta tag should not be needed and I advice against it. If it's Internet Explorers compatibility view breaking the script, disable compatibility view. If the program runs in intranet, disable compatibility view from your users. If it's an internet application, compatibility view should not be on when user visits your site in the first place.