473,397 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Page.Validate

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!!
Nov 18 '05 #1
5 2510
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" <Ji*******@discussions.microsoft.com> wrote in message
news:22**********************************@microsof t.com...
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!!

Nov 18 '05 #2
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" <no***********@safeco.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
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" <Ji*******@discussions.microsoft.com> wrote in message
news:22**********************************@microsof t.com...
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!!


Nov 18 '05 #3
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

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).
http://msdn.microsoft.com/library/en...pplusvalid.asp

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

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:eA**************@TK2MSFTNGP10.phx.gbl... 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" <no***********@safeco.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
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" <Ji*******@discussions.microsoft.com> wrote in message
news:22**********************************@microsof t.com...
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!!



Nov 18 '05 #4
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:eA**************@TK2MSFTNGP10.phx.gbl...
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" <no***********@safeco.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
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" <Ji*******@discussions.microsoft.com> wrote in message
news:22**********************************@microsof t.com...
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!!



Nov 18 '05 #5
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" <no***********@safeco.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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:eA**************@TK2MSFTNGP10.phx.gbl...
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" <no***********@safeco.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
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" <Ji*******@discussions.microsoft.com> wrote in message
news:22**********************************@microsof t.com...
> 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!!



Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Guy Hocking | last post by:
Hi there, First of all my apologies for seeming nieve and perhaps ignorant, i am new to ASP so forgive me. The Problem - I have an ASP page that has a number of list boxes in a form. These...
4
by: Mr. x | last post by:
Hello, I know about the validator on : http://validator.w3.org , which can validate html pages. I just new to this validator. How can I validate (if it can be - by this validator) aspx pages,...
7
by: ani | last post by:
I have two submit buttons in my form which need to validate two different controls on the page . How do I validate portions of the asp.net page. The two submit buttons should validate their...
3
by: Greg Krzeszkowski | last post by:
Hi, This might be a little odd but I need to implement a back/"return to previous page" function from different pages within my asp.net application. The page the back button on has a property...
1
by: Liz | last post by:
I have a page with several dropdownlists, several text boxes and several buttons which perform calculations. I need to validate one dropdownlist (not the whole page) with the click of one button. I...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
5
by: Mark A. Sam | last post by:
Hello, I know this issue has been raised many times in the past, but I couldn't find a solution from reading many posts from a google search, so I am posting it again. I placed a...
3
by: simonZ | last post by:
I had my program written in vb and asp.net 1.1. Then I rewrite my program to asp.net 2.0 and C# - it should be faster. I also included atlas in my project. I publish my site (with debug=false...
2
by: Baron Samedi | last post by:
My whole site is PHP. That means that there are various includes which make up each page so that I can have standard headers/footers/menu, etc If the content of one of these changes, it might break...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.