0

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.

Vatsal
  • 33
  • 4

1 Answers1

0

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.

Esko
  • 4,109
  • 2
  • 22
  • 37
  • I just shared the relevant code there are lot of other things that are happening on the back end, That meta tag is necessary as IE defaults things to compatibility view to avoid compatibility view we need that meta http equiv code to let ie identify... which version it should choose if compatibility view is there. – Vatsal Jan 03 '14 at 12:18
  • Ok, does this thread help you http://stackoverflow.com/questions/14611264/x-ua-compatible-content-ie-9-ie-8-ie-7-ie-edge? It also had link to this article: http://www.gwtproject.org/doc/latest/DevGuideIE9.html – Esko Jan 03 '14 at 12:49
  • I understand the usage of 'meta http-equiv="X-UA-Compatible"'. I am trying to run some asp.net code which is blocked with later browsers.ie ... IE9 and above... Was just searching for a workaround, because when I use IE8 compatible the asp.net script runs fine but destroys all the css as IE8 was really not written for css3...(border-radius, box-shadow).. things like that. – Vatsal Jan 04 '14 at 09:32