473,397 Members | 2,056 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 life cycle and Page.IsValid property

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
Jul 30 '08 #1
2 2197
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
Jul 30 '08 #2
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
Aug 1 '08 #3

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

Similar topics

2
by: John Lau | last post by:
Hi, Is there documentation that talks about the page lifecycle, the lifecycle of controls on the page, and the rendering of inline code, in a single document? Thanks, John
6
by: MooreSmnith | last post by:
When I navigate to the next page using Response.Rediect("MyNextPage.aspx") current page Page_Load event is called. What I may wrongly understood is that post back will happen whenever there is any...
4
by: owingruters | last post by:
Hi all, I've created an User control. It's an extension of a textbox wich has some extra properties so that validation becomes a lot faster. The control wordks great if autopostback is on....
5
by: Jim Heavey | last post by:
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...
0
by: Martin | last post by:
Hi, I wanted to preform my own custom validation for the entire page so i though I would implemet the IValidator interface and do all of my validation in the "Validate" method, and this works...
1
by: tshad | last post by:
How do you set the Page.IsValid property manually? I need to check if a bunch of radio buttons are set and if none are I want to display a message that you need to select one. I just have a...
3
by: Griff | last post by:
I want to build a set of compiled user controls to incorporate into a web site. The majority of user controls will be placed on specific web page and these controls would share a common...
7
by: tshad | last post by:
I have a page that is showing as: Page.IsValid = False on postback when my submit button is pressed but none of my Validators have fired so there is no error message. How do I find out what...
1
by: Andrew Jocelyn | last post by:
Hi I have couple of dropdown controls each with a requiredfieldvalidator. I clear the dropdownlist in the button click event. When the page is rendered the dropdown validator already flags it's...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.