views:

335

answers:

3

Is it possible to turn off the Request.Form validation on a per control basis? The problem is that IE 6 and IE 7 puts the content of the <button> tag into the name attribute, thus resulting in html code in the attribute which makes asp.net server shout out loud.

Notice, this only happens in IE 6 and 7 because of their erroneous interpretation of HTML 4.

A: 

You can always set the CausesValidation property to False in your button:

CausesValidation="false"
Josh
That does not work. The problem is how IE 6/7 puts html content into attributes.Say I do <button><b>hello</b></button>, then IE 6/7 incorrectly interprets the <button> tag and puts the content into an attribute. The form tries to send that attribute, but .Net freaks out because it seems like a script hack. http://www.asp.net/learn/whitepapers/request-validation/
David Andersson
A: 

How about you style your button with CSS instead of doing it inline with non-semantic markup? That will solve the problem and make for better separation of concerns between structure and presentation.

Mufasa
The whole purpose of the button element is to be able to put markup in it.The reason why I'm doing this in the first place is to be able to very distinctly separate structure from presentation. Though, this is the web world with different browsers supporting different things, thus making me use this solution.
David Andersson
I'm confused--doesn't that mean that using CSS *is* what you want?Well, anyway, you can add any attribute to an ASP.NET control and it will output it directly. So add `style="..."` to the Button's attribute/parameter list (*not* in between the opening and closing tags), and you can put CSS styles inline still.
Mufasa
My answer was a bit unclear. It's an advanced CSS manouevre I'm using to create what I want which needs the extra elements to make it work.
David Andersson
A: 

If you're talking about the HttpRequestValidationException thrown when form controls contain potential XSS exploits then take a look at my answer to a similar question. I provide the code for a class module to intercept a postback before the validation event occurs and modify the form data.

I suspect however that the problem is not a bug in IE but possibly some invalid HTML or Javascript causing you trouble.

CptSkippy