Page life cycle and Page.IsValid property

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?R2FyeSBMYXJpbWVy?=

    Page life cycle and Page.IsValid property

    I an asp.net web page with a simple form and a Submit button. Form entries
    are validated client side, but as a back up I would also like to validate
    server side, but not sure where to do it code.

    Can the Page.IsValid property be checked in the following code:

    protected void Page_Load()
    {
    if(IsPostBack)
    {
    //can IsValid be checked here on PostBack
    if(IsValdi) { //respond here if not valid }
    }
    }

    Or do I have to check IsValid in the button click handler?

    Looked at page life cycles at msdn, but am not certain when the IsValid
    property can be processed in code.

    Thanks for any comments.
    --
    Gary Larimer
  • =?Utf-8?B?WWFua2VlIEltcGVyaWFsaXN0IERvZw==?=

    #2
    RE: Page life cycle and Page.IsValid property

    you can call a Page.Validate() at various point in a page if you like to
    force validation. The reason i note this is that using

    if (Page.IsValid)
    {
    }
    will throw an error if referenced when a validate() has not been fired.

    I don't think this is a direct answer to your question, but I hope this helps.




    --
    Share The Knowledge. I need all the help I can get and so do you!


    "Gary Larimer" wrote:
    I an asp.net web page with a simple form and a Submit button. Form entries
    are validated client side, but as a back up I would also like to validate
    server side, but not sure where to do it code.
    >
    Can the Page.IsValid property be checked in the following code:
    >
    protected void Page_Load()
    {
    if(IsPostBack)
    {
    //can IsValid be checked here on PostBack
    if(IsValdi) { //respond here if not valid }
    }
    }
    >
    Or do I have to check IsValid in the button click handler?
    >
    Looked at page life cycles at msdn, but am not certain when the IsValid
    property can be processed in code.
    >
    Thanks for any comments.
    --
    Gary Larimer

    Comment

    • =?Utf-8?B?R2FyeSBMYXJpbWVy?=

      #3
      RE: Page life cycle and Page.IsValid property

      Thanks for the reply. I did try the code as shown in my post, and it did
      throw an error as you noted. So, put if(IsValid){ } in button click
      procedure where it works fine.
      --
      Gary Larimer


      "Yankee Imperialist Dog" wrote:
      you can call a Page.Validate() at various point in a page if you like to
      force validation. The reason i note this is that using
      >
      if (Page.IsValid)
      {
      }
      will throw an error if referenced when a validate() has not been fired.
      >
      I don't think this is a direct answer to your question, but I hope this helps.
      >
      >
      >
      >
      --
      Share The Knowledge. I need all the help I can get and so do you!
      >
      >
      "Gary Larimer" wrote:
      >
      I an asp.net web page with a simple form and a Submit button. Form entries
      are validated client side, but as a back up I would also like to validate
      server side, but not sure where to do it code.

      Can the Page.IsValid property be checked in the following code:

      protected void Page_Load()
      {
      if(IsPostBack)
      {
      //can IsValid be checked here on PostBack
      if(IsValdi) { //respond here if not valid }
      }
      }

      Or do I have to check IsValid in the button click handler?

      Looked at page life cycles at msdn, but am not certain when the IsValid
      property can be processed in code.

      Thanks for any comments.
      --
      Gary Larimer

      Comment

      Working...