Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Where in the page lifecycle does validation occur?

Reply
Thread Tools

Where in the page lifecycle does validation occur?

 
 
paul.hester@gmail.com
Guest
Posts: n/a
 
      08-25-2006
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

 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      08-25-2006
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: oups.com...
> 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
>



 
Reply With Quote
 
 
 
 
paul.hester@gmail.com
Guest
Posts: n/a
 
      08-25-2006
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: oups.com...
> > 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
> >


 
Reply With Quote
 
Teemu Keiski
Guest
Posts: n/a
 
      08-26-2006
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: ups.com...
> 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: oups.com...
>> > 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
>> >

>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Where in the page lifecycle does validation occur? Paul ASP .Net 3 09-08-2006 04:26 PM
Where in the page lifecycle does validation occur? paul.hester@gmail.com ASP .Net Web Controls 0 08-25-2006 08:04 AM
Page LifeCycle kinda complex Weston Weems ASP .Net 0 08-10-2004 06:14 PM
Page and control lifecycle John Lau ASP .Net 2 05-11-2004 10:25 PM
How to manage solutions that don't fit within the ASP.NET page lifecycle Epson Barnett ASP .Net 1 04-21-2004 02:27 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57