Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Building Controls / August 2006

Tip: Looking for answers? Try searching our database.

Where in the page lifecycle does validation occur?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
paul.hester@gmail.com - 25 Aug 2006 09:05 GMT
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 - 25 Aug 2006 18:10 GMT
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.

Signature

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

> Hi all,
>
[quoted text clipped - 13 lines]
>
> Paul
paul.hester@gmail.com - 25 Aug 2006 23:34 GMT
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

> Hi,
>
[quoted text clipped - 26 lines]
> >
> > Paul
Teemu Keiski - 26 Aug 2006 08:45 GMT
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.

Signature

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

> Thanks Teemu,
>
[quoted text clipped - 38 lines]
>> >
>> > Paul

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.