• Home
  • About Me
  • Musings
  • Programming
  • Open Source
  • Computers
  • Society
  • Books
  • Design
  • Movies
  • ASP.Net Validation controls

    Posted on February 20th, 2008 by Rajeshwaran S P

    ASP.Net validation controls can be used to perform both client side validations. If the page containing a asp.net validation control is rendered in a page with Javascript disabled, the asp.net runtime creates code to automatically perform the validations in the server side.

    Server side validations can be invoked using the Page.Validate() method. The status of the validation is set to the Page.IsValid property by the asp.net runtime.

    1
    2
    3
    4
    5
    6
    7
    
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Page.IsPostBack)
       {
          Page.Validate();
       }
    }
    1
    2
    3
    4
    5
    
     protected void button1_Click(object sender, EventArgs e)
    {
        if (!Page.IsValid) return;
          //Do something if validation passes.
    }

    This server side validation works on all major browsers. I have tested on IE, FireFox and Netscape.

    Possibly Related posts:

    1. .Net 4.0 Client Profile .Net 4.0 introduces the concept of Client Profile. I came...
    2. Continuous Integration with CruiseControl.Net I had challenges in understanding the documentation for installing and...
    3. Design Time Support in Custom Server Controls Visual Studio and ASP.Net provide excellent design time support for...
    4. DOCTYPE blues Yesterday I was working on the layout for a new...

    Tags: , ,

    Leave a Reply