Problem with Request Validation
In order to display some special text (like html data) I开发者_如何学编程 put validaterequest="false"
in my aspx page. But unfortunatly I'm not even get that text to display.
So how can i display that (Html enabled) content?
If you experience that validateRequest="false" has no effect, it may be helped by setting this in web.config:
<system.web>
<httpRuntime requestValidationMode="2.0" />
</system.web>
Which reverts to the behavior of the ASP.NET 2.0 request validation feature.
if you want to display the html text. Place a asp:Literal contol on the form where you want to display the text. e.g.
ASPX:
<asp:Literal ID="outputHtml" runat="Server">
CS:
outputHtml.Text = your_var_having_html;
If the TextBox is in a databound control (Repeater/GridView/etc.) and you bind the data on every postback the TextBox will lose it's contents, because all contents of the control are recreated. Use if(!Page.IsPostBack){/*code*/}
to make sure it only databinds on first load.
精彩评论