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

Discussion in 'ASP .Net Web Controls' started by Umut Tezduyar, Nov 12, 2004.

  1. 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.
    Umut Tezduyar, Nov 12, 2004
    1. Advertisements

  2. 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
    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 [MVP]" <> wrote in message
    > Umut Tezduyar wrote:
    >> 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 [] 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
    > * When you think ASP.NET, think!
    Umut Tezduyar, Nov 13, 2004
    1. Advertisements

  3. Scott Mitchell [MVP], Nov 13, 2004
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Colin Mackay
    Colin Mackay
    Jun 25, 2003
  2. buran
    Sep 26, 2003
  3. =?Utf-8?B?QmFyYmFyYSBBbGRlcnRvbg==?=

    Using Summary Validation control with server Custom validation

    =?Utf-8?B?QmFyYmFyYSBBbGRlcnRvbg==?=, Oct 15, 2004, in forum: ASP .Net
    Oct 15, 2004
  4. Matt Sokol
    Theo Tillotson
    Aug 7, 2003
  5. buran
    Sep 26, 2003

Share This Page