error while post back the page if any input control(textBox) has value &#


Im working in Asp.net 2.0 and Ajax 1.0
Im getting error while post back the page if any input control(textBox) has value &#
im not getting error even it has value #&
 Please help....
-1
ajith
11/13/2008 6:46:23 AM
📁 asp.net.ajax-ui
📃 9760 articles.
⭐ 0 followers.

💬 2 Replies
👁️‍🗨️ 2234 Views


Hi ajith P T

 
The “&#” is a special word in HTML, it might be forbid during the postback because of the security issue.
If you need this in your TextBox, you can set the ValidateRequest="false" on your <%@ Page %> tag to avoid the error.
 
Just like the following demo:
  
&lt;%@ Page Language=&quot;C#&quot; ValidateRequest=&quot;false&quot; %&gt;

&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;

&lt;script runat=&quot;server&quot;&gt;

&lt;/script&gt;

&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head runat=&quot;server&quot;&gt;
    &lt;title&gt;&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;form id=&quot;form1&quot; runat=&quot;server&quot;&gt;
    &lt;div&gt;
        &lt;asp:TextBox ID=&quot;TextBox1&quot; runat=&quot;server&quot;&gt;&lt;/asp:TextBox&gt;
    &lt;/div&gt;
    &lt;asp:Button ID=&quot;Button1&quot; runat=&quot;server&quot; Text=&quot;Button&quot; /&gt;
    &lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
 
 
Thanks.

 

Lance Zhang
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
1
Lance
11/17/2008 4:47:20 AM
You can disable request validation by setting the validateRequest attribute in the @ Page directive to false, as shown in the following example: 

<%@ Page validateRequest="false" %>
To disable request validation for your application, you must modify or create a Web.config file for your application and set the validateRequest attribute of the pages section to false, as shown in the following example:
<configuration> 
  <system.web> 
    <pages validateRequest="false" /> 
  </system.web> 
</configuration> 


This Indicates whether request validation should occur. If true, request validation checks all input data against a hard-coded list of potentially dangerous values. If a match occurs, an HttpRequestValidationException exception is thrown. The default is true.


This feature is enabled in the machine configuration file (Machine.config). You can disable it in your application configuration file (Web.config) or on the page by setting this attribute to false.


Chetan Sarode
Software Engineer,
Approva Systems Pvt Ltd,
Pune, India.
1
chetan
11/18/2008 3:38:40 AM
Reply:

Similar Artilces: