473,498 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Form Validation

Vi
Hi,
I have a form which displays some orders based on dates selected or based on
an order number. I have two different buttons for each kind of query, but
both buttons call the same method in the code behind page.
I'm validating the dates and if they're not ok, I set args.IsValid=false;
In the method that retrieves the orders, I check if Page.IsValid.
This way if the dates are not valid, the retrieval by dates is not working,
but so is the retrieval by order number. Even if I would have two different
methods, I would still check Page.IsValid and it would not work.
Is there a way to solve this problem, meaning the “get order by date” button
to depend on the validity of dates text boxes and the validity of the “get
order by order number” button to depend on the validity of the order number
text box?

Thank you.

Nov 18 '05 #1
3 1700
Try setting CausesValidation="False" then in your code behind on the
respective button click use Page.FindControl("controlid") to get the
instance of the specific validator you want, call Validate on it then check
the IsValid property.

MattC
"Vi" <Vi@discussions.microsoft.com> wrote in message
news:41**********************************@microsof t.com...
Hi,
I have a form which displays some orders based on dates selected or based on an order number. I have two different buttons for each kind of query, but
both buttons call the same method in the code behind page.
I'm validating the dates and if they're not ok, I set args.IsValid=false;
In the method that retrieves the orders, I check if Page.IsValid.
This way if the dates are not valid, the retrieval by dates is not working, but so is the retrieval by order number. Even if I would have two different methods, I would still check Page.IsValid and it would not work.
Is there a way to solve this problem, meaning the "get order by date" button to depend on the validity of dates text boxes and the validity of the "get order by order number" button to depend on the validity of the order number text box?

Thank you.

Nov 18 '05 #2
Vi
Thank you for your reply,
That almost worked. The only problem is that after I validate a control,
even if I set args.IsValid=false in the validation method, and then use
Page.IsValid in the main method, it says that I cannot use Page.IsValid
because I did not use Page.Validate() and because Button.CausesValidation =
"False".

Also, I don't know if this matters, but I have a CustomValidator and a
RequiredFieldValidator assigned to the TextBox controls for dates and a
RequiredFieldValidator assigned to the TextBox controlfor the Order#.

Thank you again

"MattC" wrote:
Try setting CausesValidation="False" then in your code behind on the
respective button click use Page.FindControl("controlid") to get the
instance of the specific validator you want, call Validate on it then check
the IsValid property.

MattC
"Vi" <Vi@discussions.microsoft.com> wrote in message
news:41**********************************@microsof t.com...
Hi,
I have a form which displays some orders based on dates selected or based

on
an order number. I have two different buttons for each kind of query, but
both buttons call the same method in the code behind page.
I'm validating the dates and if they're not ok, I set args.IsValid=false;
In the method that retrieves the orders, I check if Page.IsValid.
This way if the dates are not valid, the retrieval by dates is not

working,
but so is the retrieval by order number. Even if I would have two

different
methods, I would still check Page.IsValid and it would not work.
Is there a way to solve this problem, meaning the "get order by date"

button
to depend on the validity of dates text boxes and the validity of the

"get
order by order number" button to depend on the validity of the order

number
text box?

Thank you.


Nov 18 '05 #3
You dont need to validate the entire page as this will attempt to validate
every validator control on the page. As I said, on the button click no
validation is called.

Therefore you call validate ONLY on the validators you want to fire. Once
you have called validate you do something like this:

if(_validator1.IsValid() && _validator1.IsValid())
{
//do some stuff
}

In your case I dont think you need to validate the page as you dont want
everything to be checked only that which it related to your button click.

MattC

"Vi" <Vi@discussions.microsoft.com> wrote in message
news:DD**********************************@microsof t.com...
Thank you for your reply,
That almost worked. The only problem is that after I validate a control,
even if I set args.IsValid=false in the validation method, and then use
Page.IsValid in the main method, it says that I cannot use Page.IsValid
because I did not use Page.Validate() and because Button.CausesValidation = "False".

Also, I don't know if this matters, but I have a CustomValidator and a
RequiredFieldValidator assigned to the TextBox controls for dates and a
RequiredFieldValidator assigned to the TextBox controlfor the Order#.

Thank you again

"MattC" wrote:
Try setting CausesValidation="False" then in your code behind on the
respective button click use Page.FindControl("controlid") to get the
instance of the specific validator you want, call Validate on it then check the IsValid property.

MattC
"Vi" <Vi@discussions.microsoft.com> wrote in message
news:41**********************************@microsof t.com...
Hi,
I have a form which displays some orders based on dates selected or based
on
an order number. I have two different buttons for each kind of query,

but both buttons call the same method in the code behind page.
I'm validating the dates and if they're not ok, I set args.IsValid=false; In the method that retrieves the orders, I check if Page.IsValid.
This way if the dates are not valid, the retrieval by dates is not

working,
but so is the retrieval by order number. Even if I would have two

different
methods, I would still check Page.IsValid and it would not work.
Is there a way to solve this problem, meaning the "get order by date"

button
to depend on the validity of dates text boxes and the validity of the

"get
order by order number" button to depend on the validity of the order

number
text box?

Thank you.


Nov 18 '05 #4

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

Similar topics

17
8257
by: Phil Powell | last post by:
Where can I find an online PHP form validator script library to use? I have tried hacking the one here at work for weeks now and it's getting more and more impossible to customize, especially now...
4
9940
by: TG | last post by:
I have a validation form that must behave differently based on the results of a PHP validation check. I have a post command at the top of my form that calls itself. I don't leave the form when...
4
2609
by: bnp | last post by:
Hi All, I am quite new the JavaScript. Basically I am a C++ programmer, but now I am working on JavaScript since last 5 days. I have a problem regarding the form validation. I have created a...
16
2188
by: Hosh | last post by:
I have a form on a webpage and want to use JavaScript validation for the form fields. I have searched the web for form validation scripts and have come up with scripts that only validate...
9
4153
by: julie.siebel | last post by:
Hello all! As embarrassing as it is to admit this, I've been designing db driven websites using javascript and vbscript for about 6-7 years now, and I am *horrible* at form validation. To be...
27
4676
by: Chris | last post by:
Hi, I have a form for uploading documents and inserting the data into a mysql db. I would like to validate the form. I have tried a couple of Javascript form validation functions, but it...
11
2957
by: Rik | last post by:
Hello guys, now that I'm that I'm working on my first major 'open' forms (with uncontrolled users I mean, not a secure backend-interface), I'd like to add a lot of possibilities to check wether...
10
5683
by: gweasel | last post by:
What is the best way to apply a Validation Rule - or rather, where is the best place to put it? Is there an advantage to putting it on the field in the table vs setting the validation rule on the...
5
3200
by: lucyh3h | last post by:
Hi, I am trying to use XMLHttpRequest to do server side validation. I have several fields on a form and a submit button. The submit button has an event assocated with it when clicked. The...
7
3577
ak1dnar
by: ak1dnar | last post by:
Hi, I got this scripts from this URL There is Error when i submit the form. Line: 54 Error: 'document.getElementbyID(....)' is null or not an object What is this error. Complete Files
0
7125
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
7004
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
7208
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
7379
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
5464
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 projectplanning, coding, testing,...
0
4593
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...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1423
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 ...
1
657
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.