简体   繁体   English

在继承的按钮控件上关闭Request.Form验证

[英]Turning off Request.Form validation on inherited button control

Is it possible to turn off the Request.Form validation on a per control basis? 是否可以在每个控件的基础上关闭Request.Form验证? 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. 问题是IE 6和IE 7将<button>标记的内容放入name属性,从而导致该属性中的html代码使asp.net服务器大声喊叫。

Notice, this only happens in IE 6 and 7 because of their erroneous interpretation of HTML 4. 请注意,由于对HTML 4的错误解释,这只会在IE 6和7中发生。

How about you style your button with CSS instead of doing it inline with non-semantic markup? 您如何使用CSS设置按钮样式,而不是使用非语义标记直接内嵌按钮? That will solve the problem and make for better separation of concerns between structure and presentation. 这将解决问题,并使结构和表示之间的关注点更好地分离。

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 . 如果您谈论的是表单控件包含潜在的XSS漏洞时引发的HttpRequestValidationException,那么请看一下我对类似问题的回答 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. 但是我怀疑问题不是IE中的错误,而是可能是某些无效的HTML或Javascript引起了您的麻烦。

您可以始终在按钮中将CausesValidation属性设置为False:

CausesValidation="false"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM