Where in the page lifecycle does validation occur?

Discussion in 'ASP .Net Building Controls' started by paul.hester@gmail.com, Aug 25, 2006.

  1. Guest

    Hi all,

    I don't use auto postbacks on my web site to keep it javascript-free
    and browser agnostic. Whenever there's a postback to my page I'm using
    the Page_Load event to use the posted data for database updates.
    However, the page hasn't been validated at this point. I can call
    Validate() at this point, but this means the controls will be validated
    twice.

    At what point in the page lifecycle are the controls validated? When
    would be the best time and place to use the posted data for a database
    update, if not using auto postbacks? My current method doesn't seem
    ideal.

    Thanks in advance,

    Paul
     
    , Aug 25, 2006
    #1
    1. Advertising

  2. Teemu Keiski Guest

    Hi,

    it happens just before postback events are raised (after Page_Load). In
    practise, if you have a Button on Page which triggers validation, it happens
    just before Button's Click event is raised. In the Button's Click event, you
    could then just check Page.IsValid.

    --
    Teemu Keiski
    ASP.NET MVP, AspInsider
    Finland, EU
    http://blogs.aspadvice.com/joteke

    <> wrote in message
    news:...
    > Hi all,
    >
    > I don't use auto postbacks on my web site to keep it javascript-free
    > and browser agnostic. Whenever there's a postback to my page I'm using
    > the Page_Load event to use the posted data for database updates.
    > However, the page hasn't been validated at this point. I can call
    > Validate() at this point, but this means the controls will be validated
    > twice.
    >
    > At what point in the page lifecycle are the controls validated? When
    > would be the best time and place to use the posted data for a database
    > update, if not using auto postbacks? My current method doesn't seem
    > ideal.
    >
    > Thanks in advance,
    >
    > Paul
    >
     
    Teemu Keiski, Aug 25, 2006
    #2
    1. Advertising

  3. Guest

    Thanks Teemu,

    If I don't want to use button events (to avoid the need for javascript)
    where's the best place to check if the posted data is valid and do
    database updates, redirects etc.?

    Thanks,

    Paul

    Teemu Keiski wrote:
    > Hi,
    >
    > it happens just before postback events are raised (after Page_Load). In
    > practise, if you have a Button on Page which triggers validation, it happens
    > just before Button's Click event is raised. In the Button's Click event, you
    > could then just check Page.IsValid.
    >
    > --
    > Teemu Keiski
    > ASP.NET MVP, AspInsider
    > Finland, EU
    > http://blogs.aspadvice.com/joteke
    >
    > <> wrote in message
    > news:...
    > > Hi all,
    > >
    > > I don't use auto postbacks on my web site to keep it javascript-free
    > > and browser agnostic. Whenever there's a postback to my page I'm using
    > > the Page_Load event to use the posted data for database updates.
    > > However, the page hasn't been validated at this point. I can call
    > > Validate() at this point, but this means the controls will be validated
    > > twice.
    > >
    > > At what point in the page lifecycle are the controls validated? When
    > > would be the best time and place to use the posted data for a database
    > > update, if not using auto postbacks? My current method doesn't seem
    > > ideal.
    > >
    > > Thanks in advance,
    > >
    > > Paul
    > >
     
    , Aug 25, 2006
    #3
  4. Teemu Keiski Guest

    Just before you need the data. generally you'd want to use events as they
    help in keeping the page code structure clean. Otherwise you have code
    centralized in one place trying to deal all cases.

    Note that Js validation isnt that bad, you have server-side validation
    backing it up in any case.

    --
    Teemu Keiski
    ASP.NET MVP, AspInsider
    Finland, EU
    http://blogs.aspadvice.com/joteke


    <> wrote in message
    news:...
    > Thanks Teemu,
    >
    > If I don't want to use button events (to avoid the need for javascript)
    > where's the best place to check if the posted data is valid and do
    > database updates, redirects etc.?
    >
    > Thanks,
    >
    > Paul
    >
    > Teemu Keiski wrote:
    >> Hi,
    >>
    >> it happens just before postback events are raised (after Page_Load). In
    >> practise, if you have a Button on Page which triggers validation, it
    >> happens
    >> just before Button's Click event is raised. In the Button's Click event,
    >> you
    >> could then just check Page.IsValid.
    >>
    >> --
    >> Teemu Keiski
    >> ASP.NET MVP, AspInsider
    >> Finland, EU
    >> http://blogs.aspadvice.com/joteke
    >>
    >> <> wrote in message
    >> news:...
    >> > Hi all,
    >> >
    >> > I don't use auto postbacks on my web site to keep it javascript-free
    >> > and browser agnostic. Whenever there's a postback to my page I'm using
    >> > the Page_Load event to use the posted data for database updates.
    >> > However, the page hasn't been validated at this point. I can call
    >> > Validate() at this point, but this means the controls will be validated
    >> > twice.
    >> >
    >> > At what point in the page lifecycle are the controls validated? When
    >> > would be the best time and place to use the posted data for a database
    >> > update, if not using auto postbacks? My current method doesn't seem
    >> > ideal.
    >> >
    >> > Thanks in advance,
    >> >
    >> > Paul
    >> >

    >
     
    Teemu Keiski, Aug 26, 2006
    #4
    1. Advertising

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. Miguel Dias Moura
    Replies:
    4
    Views:
    462
    Hans Kesting
    May 6, 2004
  2. dustbort
    Replies:
    2
    Views:
    2,863
    dustbort
    Feb 28, 2006
  3. Paul
    Replies:
    3
    Views:
    461
  4. bogdan
    Replies:
    1
    Views:
    2,418
    Teemu Keiski
    Mar 20, 2008
  5. Replies:
    0
    Views:
    130
Loading...

Share This Page