Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Page life cycle and Page.IsValid property

Reply
Thread Tools

Page life cycle and Page.IsValid property

 
 
Gary Larimer
Guest
Posts: n/a
 
      07-30-2008
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
 
Reply With Quote
 
 
 
 
Yankee Imperialist Dog
Guest
Posts: n/a
 
      07-30-2008
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

 
Reply With Quote
 
 
 
 
Gary Larimer
Guest
Posts: n/a
 
      08-01-2008
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

 
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
What does "Page Load" and "Page Unload", "Page Life Cycle" exactlymean???? lander ASP .Net 5 03-03-2008 02:06 PM
App_Code and the Page Life Cycle clintonG ASP .Net 2 07-15-2006 02:33 PM
asp.net 1.1 page and controls life-cycle Fred ASP .Net 5 01-23-2006 02:19 PM
How to avoid two DB calls during page life cycle. Peter Rilling ASP .Net 5 03-09-2005 06:48 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