473,756 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do you check if validate has been called.

I get the following message from one of my buttons where I have
CauseValidation =false.

Page.IsValid cannot be called before validation has taken place

In my routine I need to do:

if Not IsValid then
exit sub
end if

This is because I have a custom validator on some of my fields and I need to
check this as the function will run regardless of the results of the cusom
validators.

The problem is that I may press the button before any validation has taken
place, which is why I get the error.

Is there a way to check if any validation has taken place, such that I might
do something like:

if some validation done then
if Not IsValid then
exit sub
end if
end if

Thanks,

Tom
Nov 19 '05 #1
8 5403
Are you trying to check Page.IsValid inside of your custom validation events?
This will give back incorrect results since the order of your validators
and the other validators isn't guarenteed.

If you're trying to do this in Page_Load then just call Page.Validate() first.

-Brock
DevelopMentor
http://staff.develop.com/ballen
I get the following message from one of my buttons where I have
CauseValidation =false.

Page.IsValid cannot be called before validation has taken place

In my routine I need to do:

if Not IsValid then
exit sub
end if
This is because I have a custom validator on some of my fields and I
need to check this as the function will run regardless of the results
of the cusom validators.

The problem is that I may press the button before any validation has
taken place, which is why I get the error.

Is there a way to check if any validation has taken place, such that I
might do something like:

if some validation done then
if Not IsValid then
exit sub
end if
end if
Thanks,

Tom


Nov 19 '05 #2
"Brock Allen" <ba****@NOSPAMd evelop.com> wrote in message
news:31******** **************@ msnews.microsof t.com...
Are you trying to check Page.IsValid inside of your custom validation
events? This will give back incorrect results since the order of your
validators and the other validators isn't guarenteed.
It is a routine that is called by one of my buttons that does not cause
Validation. But I do want to check if the page has been validated and if
NOT - do one thing. If it has gone through validation - do something else.

I don't want to Validate, just check if it has been validated. But I can't
look at Page.IsValid if validation has not been called.

Tom
If you're trying to do this in Page_Load then just call Page.Validate()
first.

-Brock
DevelopMentor
http://staff.develop.com/ballen
I get the following message from one of my buttons where I have
CauseValidation =false.

Page.IsValid cannot be called before validation has taken place

In my routine I need to do:

if Not IsValid then
exit sub
end if
This is because I have a custom validator on some of my fields and I
need to check this as the function will run regardless of the results
of the cusom validators.

The problem is that I may press the button before any validation has
taken place, which is why I get the error.

Is there a way to check if any validation has taken place, such that I
might do something like:

if some validation done then
if Not IsValid then
exit sub
end if
end if
Thanks,

Tom


Nov 19 '05 #3
> I don't want to Validate, just check if it has been validated. But I
can't look at Page.IsValid if validation has not been called.


Validate always happens after Page_Load but before your server change events
and server click events.

-Brock
DevelopMentor
http://staff.develop.com/ballen

Nov 19 '05 #4
"Brock Allen" <ba****@NOSPAMd evelop.com> wrote in message
news:38******** **************@ msnews.microsof t.com...
I don't want to Validate, just check if it has been validated. But I
can't look at Page.IsValid if validation has not been called.
Validate always happens after Page_Load but before your server change

events and server click events.
That isn't the question. I am not concerned about at what point in a page
load Validation is done.

My problem is that I press a submit button, that I specifically tell not to
validate, that calls a routine where I am checking IsValid. I am getting an
error because if the page was never validated, this is an error (to check
IsValid).

What I want to do in the routine is check if validation has been done before
I check "IsValid", so I don't get the error.

Thanks,

Tom
-Brock
DevelopMentor
http://staff.develop.com/ballen

Nov 19 '05 #5
> My problem is that I press a submit button, that I specifically tell
not to validate, that calls a routine where I am checking IsValid. I
am getting an error because if the page was never validated, this is
an error (to check IsValid).

What I want to do in the routine is check if validation has been done
before I check "IsValid", so I don't get the error.


You can always check the sender of the event, cast it to a Button and check
CausesValidatio n to get the results you want. If it's true then you can check
IsValid if it's false then you can't.

-Brock
DevelopMentor
http://staff.develop.com/ballen

Nov 19 '05 #6
"Brock Allen" <ba****@NOSPAMd evelop.com> wrote in message
news:42******** **************@ msnews.microsof t.com...
My problem is that I press a submit button, that I specifically tell
not to validate, that calls a routine where I am checking IsValid. I
am getting an error because if the page was never validated, this is
an error (to check IsValid).

What I want to do in the routine is check if validation has been done
before I check "IsValid", so I don't get the error.
You can always check the sender of the event, cast it to a Button and
check CausesValidatio n to get the results you want. If it's true then you
can check IsValid if it's false then you can't.


But that doesn't tell me if another button causes validation or not.

For example, if I have 2 buttons, button A doesn't call validation and
button B does.

If button A is pushed before button B and I do a "if Not IsValid", then I
will get an error.

Testing button A to see if it causes validation doesn't tell me if another
button has caused it or not.

Tom
-Brock
DevelopMentor
http://staff.develop.com/ballen

Nov 19 '05 #7
> But that doesn't tell me if another button causes validation or not.

Hmm, ok. Well, I'm sorry that I'm just not getting what you're looking for.
:(
For example, if I have 2 buttons, button A doesn't call validation and
button B does.
Do you have them calling the same server side event handler or different
events handlers?
If button A is pushed before button B and I do a "if Not IsValid",
then I will get an error.
But once you click one button that causes the postback. You don't tend to
get two button clicks on a single postback. If you have two roundtrips (meaning
two button clicks) then it's possible that between postbacks the values of
controls have changed, thus the valid state may have changed. I'm not sure
that helps you, since I don't know what you need.
Testing button A to see if it causes validation doesn't tell me if
another button has caused it or not.


Again, sorry I don't toally grok what what you're trying to do... but perhaps
the validation architecture just doesn't support it. *shrug*

-Brock
DevelopMentor
http://staff.develop.com/ballen

Nov 19 '05 #8
The issue is solved in http://forums.asp.net/thread/1527065.aspx

It explains following code snippet:

using System.Web;
using System.Web.UI;
using System.Reflecti on;

public class PageUtil
{
public static bool IsPageValidated ()
{
Page page = HttpContext.Cur rent.Handler as Page;
if (page == null) throw new HttpException(" This method can be called only in classes derived from System.Web.UI.P age");
FieldInfo fieldValidated = typeof(Page).Ge tField("_valida ted", BindingFlags.In stance | BindingFlags.No nPublic);
return (bool)fieldVali dated.GetValue( page);
}
}

From http://www.developmentnow.com/g/8_20...en-called-.htm

Posted via DevelopmentNow. com Groups
http://www.developmentnow.com
Jan 11 '07 #9

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

Similar topics

6
12357
by: Xerxes | last post by:
Hi, how can I check if an input field in a form is defined? I create the field dynamically, so it could or could not be in the form. TIA.
5
6316
by: Steve Wylie | last post by:
I am constructing an HTML questionnaire and one of the questions requires people to rate some choices from 1 to 5, where 1 is their favourite and 5 is their least favourite: Car Bus Taxi cab Train Airplane
5
2433
by: Anthony Robinson | last post by:
Consider the following tables: CREATE TABLE "AIMD "."CHANNELSESSION" ( "CHANNELSESSIONID" DECIMAL(13,0) NOT NULL GENERATED ALWAYS AS IDENTITY ( START WITH +1 , INCREMENT BY +1 , CACHE 20 ) , "CONNECTSTARTTIME" TIMESTAMP NOT NULL , "CONNECTENDTIME" TIMESTAMP , "ACTIVESESSION" VARCHAR(1), "CHANNELID" DECIMAL(12,0) NOT NULL ) IN "USERSPACE1" ;
2
1784
by: John H | last post by:
Hi, How can i just use the XmlDocument object to validate an xml instanace against a schema referenced inside the xml instance? The Load method seems to not validate it against the schema. Thanks John
5
2546
by: eyoung | last post by:
I have a function to check a string to make sure it is 6 digites using the trigger onBlur="CkFrmt(this)" Problem is I've got 4 fields in a row...if I enter a wrong number in the first and hit tab I get the error message and my script tries to move the focus to the first item...but because I hit the tab the focus in already on the second item which does not contain a 6 digit value so I must kill the page. help! function CkFrmt(str) {
18
2756
by: Joel Hedlund | last post by:
Hi! The question of type checking/enforcing has bothered me for a while, and since this newsgroup has a wealth of competence subscribed to it, I figured this would be a great way of learning from the experts. I feel there's a tradeoff between clear, easily readdable and extensible code on one side, and safe code providing early errors and useful tracebacks on the other. I want both! How do you guys do it? What's the pythonic way? Are...
9
15527
by: webrod | last post by:
Hi all, how can I check a user/password in a LDAP ? I don't want to connect with this user, I would like to connect to LDAP with a ADMIN_LOG/ADMIN_PWD, then do a query to find the user and check the password. The thing is I can't access the password attribute to compare with the user's password provided.
1
1531
by: Alexio | last post by:
I am a newbie to this and am having a problem with validation and keeping data that has been entered in other fields when submitting the form. For the check boxes, I need a minimum of one selected. If one is not selected, a message box appears notifying that a check box has not been selected. When I click OK, the data in the other text boxes is removed as if the form is being reloaded. How can I prevent this from happening. Is there a better...
2
5743
by: thj | last post by:
Hi. I've got this form that I'm trying to validate: <form id="periodForm" action="" method="post"> <p> Periode: <input id="startDate" name="startDate" type="text" size="7" value="<%= ViewData %>" /> -
0
9455
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10031
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9869
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9838
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8709
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7242
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5302
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3805
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.