如何在一个特定的文本框禁用HTML标记验证?文本框、标记、如何在、HTML

2023-09-07 17:03:01 作者:越发觉得痛

我有一个表格,其中的一个字段将允许HTML标签的条目。

I have a form where one of the fields would allow entry of HTML tags.

<asp:TextBox ID="someID" runat="server" TextMode="MultiLine" />

在这个领域我只有一个的RequiredFieldValidator 验证。不幸的是,如果任何字段的内容包括HTML标记或任何其他潜在危险的code任何回发后 - 整个ViewState中被清洗

In this field I have a RequiredFieldValidator validation only. Unfortunately, after any PostBack if the content of any of the fields includes HTML tags or any other potentially dangerous code - the entire ViewState is cleaned.

ValidateRequest 设置为并没有帮助。

我使用的是IIS 7.5和.NET 4.0。

I'm using IIS 7.5 and .NET 4.0.

任何想法?

推荐答案

您还需要设置

 <system.web>
       <httpRuntime requestValidationMode="2.0"/>
 </system.web>

除了:&LT;%@页ValidateRequest =假&GT; 在页面顶部

如果要禁用请求验证为整个应用程序,设置:

If you want to disable request validation for whole application, set :

<system.web>
      <pages validateRequest="false" />
</system.web>