Custom Button Problem WebControlAdapter IE7
I'm having a little problem implementing a custom WebControlAdapter button for. I am following the sliding door pattern to output the following HTML:
<button value="submit" name="Button1" id="Button1" type="Submit" onclick="__doPostBack('Button1','')"><span>Button</span></button>
instead of the standard:
<input id="Button1" type="submit" value="Button" name="Button1"/>
This is done (among other reasons) so the button will change depending on the text it contains, so not just for aesthetic reasons. This method works well in all browsers except IE7, and I assume it does before (IE8 works well). I traced the issue with IE7 postponing the content of the button element as opposed to the value. This means that a span tag is returned, which ASP.NET calls:
[HttpRequestValidationException (0x80004005): A potentially dangerous Request.Form value was detected from the client (Button1="<SPAN>Button</SPAN>").]
What is the correct behavior. I understand that I can disable this behavior using the Page.ValidateRequest property, however, since this is an existing application, this will cause major changes on every page to manually protect the application from Cross Site Scripting attacks.
Does anyone know how I can make this work for IE7 and earlier?
Any ideas would be appreciated.
Thanks in advance.
I had a similar problem as you, but found the answer here: what-disadvantages-are-there-to-the-button-tag-it-seems-there-are-quite-a-fe
Adding this code to my tag fixed it:
<!--[if lt IE 8]> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE8.js"></script> <![endif]-->
source to share