How can i disable validation of a page in my custom control.

U

Umut Tezduyar

I want to disable RequestValidation that consumers of my custom control. Is
there a way for this.

Infact my problem is:

By using the control that i am developing, my users can write html from the
web site. But framework 1.1 is disables it by default.
@Page RequestValidation=true. I want to disable it or allow only from some
of my controls can post html text. Is there a way for this.
 
U

Umut Tezduyar

I found something different. Can i erase the error on the OnError method
of the application.
Server.ClearError (), i dont know why, stops the request cycle of the
control.
Instead of informing my users, i strictly want to find a way to do this.
Can i change the web.config file, when my user drags and drop my control
from the toolbox.

void OnError (sender and eventargs)
{
Exception ex = Server.GetLastException ();
if (ex is RequestValidateException)
Server.ClearError ();
}

Scott Mitchell said:
Umut said:
I want to disable RequestValidation that consumers of my custom control.

Umut, I don't believe there is a way to do this from a custom control,
sorry. The directives in an ASP.NET page are read by the PageParser class
(or one of its base types), and do not have corresponding properties in
the Page class, or other classes available to controls on a page.

In fact, if you use Reflector [http://www.aisto.com/roeder/dotnet/] and
poke around deep enough in the .NET Framework source code, you'll find
that the HttpRequest class has a ValidateInput() method that essentially
performs the Request Validation. Now, what happens is when the page is
visited for the first time (or for the first time after its HTML portion
has been changed), a class is autogenerated based on the HTML content, a
class that builds up the page's control hierarchy when the page is
requested that time, and future times (until a change to the HTML
portion).

Now, if RequestValidation is turned on, it actually adds a line of code to
the autogenerated class, calling Request.ValidateInput(). So there's no
way to circumvent this, at least not one I can see. Rather, you must
instruct your users to add RequestValidation="False" in the @Page
directive, or have them set it site-wide in the Web.config file (or Web
server-wide in the Machine.config file).


hth!

--

Scott Mitchell
(e-mail address removed)
http://www.4GuysFromRolla.com

* When you think ASP.NET, think 4GuysFromRolla.com!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top