Connecting Tech Pros Worldwide Forums | Help | Site Map

Page.Validate

Jim Heavey
Guest
 
Posts: n/a
#1: Nov 18 '05
When should you use the Page.Validate() method? I thought you would use this method if you have some Server side validation (CustomControl's) you wanted to use and this would cause them to be invoked. I am probably wrong about that.

If I am suppose to use this function, the edits seemed to be invoked even when you have pressed the cancel and the "CausesValidation" is set to false. Is there a way to get around this (might just be an acedemic question if I should not be running Page.Validate() if the first place.

Thanks in advance for your assistance!!

bruce barker
Guest
 
Posts: n/a
#2: Nov 18 '05

re: Page.Validate


if the browser is not ie, or javascript is disabled, all validation is
serverside. for serverside validation to run you must call Page.Validate or
Page.IsValid.

-- bruce (sqlwork.com)


"Jim Heavey" <JimHeavey@discussions.microsoft.com> wrote in message
news:22D55F42-5B1E-4DDB-94C8-5A6AEACA6085@microsoft.com...[color=blue]
> When should you use the Page.Validate() method? I thought you would use[/color]
this method if you have some Server side validation (CustomControl's) you
wanted to use and this would cause them to be invoked. I am probably wrong
about that.[color=blue]
>
> If I am suppose to use this function, the edits seemed to be invoked even[/color]
when you have pressed the cancel and the "CausesValidation" is set to false.
Is there a way to get around this (might just be an acedemic question if I
should not be running Page.Validate() if the first place.[color=blue]
>
> Thanks in advance for your assistance!![/color]


Greg Burns
Guest
 
Posts: n/a
#3: Nov 18 '05

re: Page.Validate


Page.Validate is not the same as Page.IsValid (obviously)

I've never found a reason to call Page.Validate myself (not that there
probably aren't some good ones). Here is a contrived example from the help
files.

Sub Page_Load
If Not IsPostBack
' Validate initially to force the asterisks
' to appear before the first roundtrip.
Validate()
End If
End Sub

I always do a check of Page.IsValid first thing in my button click events.

If Not Page.IsValid Then Return

Like Bruce said, if (for whatever reason) your client-side javascript didn't
prevent the page from posting in the first place then the server validate
events will run. You use Page.IsValid to make sure that the server
validation didn't catch anything.

HTH,
Greg


"bruce barker" <nospam_brubar@safeco.com> wrote in message
news:%235lS05BcEHA.808@tk2msftngp13.phx.gbl...[color=blue]
> if the browser is not ie, or javascript is disabled, all validation is
> serverside. for serverside validation to run you must call Page.Validate[/color]
or[color=blue]
> Page.IsValid.
>
> -- bruce (sqlwork.com)
>
>
> "Jim Heavey" <JimHeavey@discussions.microsoft.com> wrote in message
> news:22D55F42-5B1E-4DDB-94C8-5A6AEACA6085@microsoft.com...[color=green]
> > When should you use the Page.Validate() method? I thought you would use[/color]
> this method if you have some Server side validation (CustomControl's) you
> wanted to use and this would cause them to be invoked. I am probably[/color]
wrong[color=blue]
> about that.[color=green]
> >
> > If I am suppose to use this function, the edits seemed to be invoked[/color][/color]
even[color=blue]
> when you have pressed the cancel and the "CausesValidation" is set to[/color]
false.[color=blue]
> Is there a way to get around this (might just be an acedemic question if I
> should not be running Page.Validate() if the first place.[color=green]
> >
> > Thanks in advance for your assistance!![/color]
>
>[/color]


Greg Burns
Guest
 
Posts: n/a
#4: Nov 18 '05

re: Page.Validate


Here is a good reason (submitted by DujHoD in prior post) to call
Page.Validate that I'd forgotten.

----------------------
I believe you can use the IsValid property of the validator itself to
check this.

http://msdn.microsoft.com/library/en...ValidTopic.asp

[color=blue]
> Note that validation happens AFTER the Page_Load event, so if you get
> this property in the Page_Load event, it will always return True,
> since the control has not yet been validated. If you must check
> validity in the Page_Load event, you can manually call the
> Page.Validate method (or just call the Validate method of the
> validator you want to check on).[/color]

http://msdn.microsoft.com/library/en...pplusvalid.asp

------------------
Greg

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:eAIM97CcEHA.2908@TK2MSFTNGP10.phx.gbl...[color=blue]
> Page.Validate is not the same as Page.IsValid (obviously)
>
> I've never found a reason to call Page.Validate myself (not that there
> probably aren't some good ones). Here is a contrived example from the[/color]
help[color=blue]
> files.
>
> Sub Page_Load
> If Not IsPostBack
> ' Validate initially to force the asterisks
> ' to appear before the first roundtrip.
> Validate()
> End If
> End Sub
>
> I always do a check of Page.IsValid first thing in my button click events.
>
> If Not Page.IsValid Then Return
>
> Like Bruce said, if (for whatever reason) your client-side javascript[/color]
didn't[color=blue]
> prevent the page from posting in the first place then the server validate
> events will run. You use Page.IsValid to make sure that the server
> validation didn't catch anything.
>
> HTH,
> Greg
>
>
> "bruce barker" <nospam_brubar@safeco.com> wrote in message
> news:%235lS05BcEHA.808@tk2msftngp13.phx.gbl...[color=green]
> > if the browser is not ie, or javascript is disabled, all validation is
> > serverside. for serverside validation to run you must call Page.Validate[/color]
> or[color=green]
> > Page.IsValid.
> >
> > -- bruce (sqlwork.com)
> >
> >
> > "Jim Heavey" <JimHeavey@discussions.microsoft.com> wrote in message
> > news:22D55F42-5B1E-4DDB-94C8-5A6AEACA6085@microsoft.com...[color=darkred]
> > > When should you use the Page.Validate() method? I thought you would[/color][/color][/color]
use[color=blue][color=green]
> > this method if you have some Server side validation (CustomControl's)[/color][/color]
you[color=blue][color=green]
> > wanted to use and this would cause them to be invoked. I am probably[/color]
> wrong[color=green]
> > about that.[color=darkred]
> > >
> > > If I am suppose to use this function, the edits seemed to be invoked[/color][/color]
> even[color=green]
> > when you have pressed the cancel and the "CausesValidation" is set to[/color]
> false.[color=green]
> > Is there a way to get around this (might just be an acedemic question if[/color][/color]
I[color=blue][color=green]
> > should not be running Page.Validate() if the first place.[color=darkred]
> > >
> > > Thanks in advance for your assistance!![/color]
> >
> >[/color]
>
>[/color]


bruce barker
Guest
 
Posts: n/a
#5: Nov 18 '05

re: Page.Validate


IsValid calls Validate() if it has not been called.

-- bruce (sqlwork.com)


"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:eAIM97CcEHA.2908@TK2MSFTNGP10.phx.gbl...[color=blue]
> Page.Validate is not the same as Page.IsValid (obviously)
>
> I've never found a reason to call Page.Validate myself (not that there
> probably aren't some good ones). Here is a contrived example from the[/color]
help[color=blue]
> files.
>
> Sub Page_Load
> If Not IsPostBack
> ' Validate initially to force the asterisks
> ' to appear before the first roundtrip.
> Validate()
> End If
> End Sub
>
> I always do a check of Page.IsValid first thing in my button click events.
>
> If Not Page.IsValid Then Return
>
> Like Bruce said, if (for whatever reason) your client-side javascript[/color]
didn't[color=blue]
> prevent the page from posting in the first place then the server validate
> events will run. You use Page.IsValid to make sure that the server
> validation didn't catch anything.
>
> HTH,
> Greg
>
>
> "bruce barker" <nospam_brubar@safeco.com> wrote in message
> news:%235lS05BcEHA.808@tk2msftngp13.phx.gbl...[color=green]
> > if the browser is not ie, or javascript is disabled, all validation is
> > serverside. for serverside validation to run you must call Page.Validate[/color]
> or[color=green]
> > Page.IsValid.
> >
> > -- bruce (sqlwork.com)
> >
> >
> > "Jim Heavey" <JimHeavey@discussions.microsoft.com> wrote in message
> > news:22D55F42-5B1E-4DDB-94C8-5A6AEACA6085@microsoft.com...[color=darkred]
> > > When should you use the Page.Validate() method? I thought you would[/color][/color][/color]
use[color=blue][color=green]
> > this method if you have some Server side validation (CustomControl's)[/color][/color]
you[color=blue][color=green]
> > wanted to use and this would cause them to be invoked. I am probably[/color]
> wrong[color=green]
> > about that.[color=darkred]
> > >
> > > If I am suppose to use this function, the edits seemed to be invoked[/color][/color]
> even[color=green]
> > when you have pressed the cancel and the "CausesValidation" is set to[/color]
> false.[color=green]
> > Is there a way to get around this (might just be an acedemic question if[/color][/color]
I[color=blue][color=green]
> > should not be running Page.Validate() if the first place.[color=darkred]
> > >
> > > Thanks in advance for your assistance!![/color]
> >
> >[/color]
>
>[/color]


Greg Burns
Guest
 
Posts: n/a
#6: Nov 18 '05

re: Page.Validate


Interesting, I've never heard that before.

I know Validate gets called automatically sometime after Page_Load. But if
you want to use IsValid in Page_Load I thougth you had to precedeed with a
Validate.

From docs:
"Note If you want to perform this check during Page_Load, you must
manually call the Validate method first."

http://msdn.microsoft.com/library/de...mmatically.asp

Greg


"bruce barker" <nospam_brubar@safeco.com> wrote in message
news:%23HKXfgEcEHA.1652@TK2MSFTNGP09.phx.gbl...[color=blue]
> IsValid calls Validate() if it has not been called.
>
> -- bruce (sqlwork.com)
>
>
> "Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
> news:eAIM97CcEHA.2908@TK2MSFTNGP10.phx.gbl...[color=green]
> > Page.Validate is not the same as Page.IsValid (obviously)
> >
> > I've never found a reason to call Page.Validate myself (not that there
> > probably aren't some good ones). Here is a contrived example from the[/color]
> help[color=green]
> > files.
> >
> > Sub Page_Load
> > If Not IsPostBack
> > ' Validate initially to force the asterisks
> > ' to appear before the first roundtrip.
> > Validate()
> > End If
> > End Sub
> >
> > I always do a check of Page.IsValid first thing in my button click[/color][/color]
events.[color=blue][color=green]
> >
> > If Not Page.IsValid Then Return
> >
> > Like Bruce said, if (for whatever reason) your client-side javascript[/color]
> didn't[color=green]
> > prevent the page from posting in the first place then the server[/color][/color]
validate[color=blue][color=green]
> > events will run. You use Page.IsValid to make sure that the server
> > validation didn't catch anything.
> >
> > HTH,
> > Greg
> >
> >
> > "bruce barker" <nospam_brubar@safeco.com> wrote in message
> > news:%235lS05BcEHA.808@tk2msftngp13.phx.gbl...[color=darkred]
> > > if the browser is not ie, or javascript is disabled, all validation is
> > > serverside. for serverside validation to run you must call[/color][/color][/color]
Page.Validate[color=blue][color=green]
> > or[color=darkred]
> > > Page.IsValid.
> > >
> > > -- bruce (sqlwork.com)
> > >
> > >
> > > "Jim Heavey" <JimHeavey@discussions.microsoft.com> wrote in message
> > > news:22D55F42-5B1E-4DDB-94C8-5A6AEACA6085@microsoft.com...
> > > > When should you use the Page.Validate() method? I thought you would[/color][/color]
> use[color=green][color=darkred]
> > > this method if you have some Server side validation (CustomControl's)[/color][/color]
> you[color=green][color=darkred]
> > > wanted to use and this would cause them to be invoked. I am probably[/color]
> > wrong[color=darkred]
> > > about that.
> > > >
> > > > If I am suppose to use this function, the edits seemed to be invoked[/color]
> > even[color=darkred]
> > > when you have pressed the cancel and the "CausesValidation" is set to[/color]
> > false.[color=darkred]
> > > Is there a way to get around this (might just be an acedemic question[/color][/color][/color]
if[color=blue]
> I[color=green][color=darkred]
> > > should not be running Page.Validate() if the first place.
> > > >
> > > > Thanks in advance for your assistance!!
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


Closed Thread