Validator Question

  • Thread starter Thread starter Q. John Chen
  • Start date Start date
Q

Q. John Chen

Following is the code from msdn:
private void Button1_Click(object sender, System.EventArgs e)
{
RangeValidator1.MinimumValue = txtArrival.Text;
RangeValidator1.MaximumValue = txtDeparture.Text;
RangeValidator1.Type = ValidationDataType.Date;
RangeValidator1.Validate();
if (!RangeValidator1.IsValid)
{
RangeValidator1.ErrorMessage = "The tour date must " +
"fall between the arrival and departure dates.";
}
}

It calls the Validate when the user entered the value.

My question. The validation control perform validate automatically. So
my guess is that the Validate() is already called AUTOMATICALLY BEFORE
the click event.

Am I right? or,
Is there a way to stop the autmatically calling of the validate()
method?

I my application, I actually have a customer Validator and no client
side validation.

Thanks

JOhn
 
This can be changed by setting the EnableClientSideScript attribute to
false.

After doing this, to check if the page is valid you'll have to use
if(Page.IsValid) in your code behind
 
My question is not about client script.

I am asking that whether or not Validate() is already called
AUTOMATICALLY BEFORE
the click event (After page_load).

If so, how can I provent the automation calling?
 
Back
Top