thanks
-----Original Message-----
From: Shannon Horn [mailto:shannon_horn@w...]
Sent: Wednesday, July 17, 2002 3:30 PM
To: ASPX_Professional
Cc: 'Brandon Searles'
Subject: [aspx_professional] RE: validating SOME fields on an event in a
web form
I believe we recently had the same problem where we wanted to validate
certain controls only when a certain condition is true or only when a
certain event is fired. We got this to work by initially disabling all
of the validation controls (such as the RequireFieldValidator). Thus,
they will not fire in that state.
When the event is fired where you want the validation controls to fire,
the very first line(s) of code in the event enable the validation
controls. The next line calls Page.Validate(). The line after that is an
if statement that checks Page.IsValid as follows:
protected void SQLDMOConnect(object sender, System.EventArgs e)
{
// Enable the password required field validator.
rfvPassword.Enabled =3D true;
// Validate the page.
Page.Validate();
// If the page validates fine, then continue on.
if (Page.IsValid)
{
// Do something.
}
else
{
// Do something else.
}
In the case where the page is not valid, an else is really not required.
And if it is not used, the validating control will fire as though it
were enabled. In our case, we had some code in the else to reset
controls to their default state prior to the validating control firing.
Hope this helps.
-----Original Message-----
From: jeby [mailto:jeby@c...]
Sent: Tuesday, July 09, 2002 21:50
To: ASPX_Professional
Subject: [aspx_professional] validating SOME fields on an event in a web
form
Hi,
My problem is this:
I have two buttons on which some validations occur.
Now I have the option of either validating all the validator controls or
not validating a single one (by setting causesValidation attribute).
I want to validate only some validator controls (i e. some fields) on
click of a button.
Help!!
Best Regards,
Jeby George