custom validation

  • Thread starter Thread starter Tarscher
  • Start date Start date
T

Tarscher

Hi all,

I have a custom validation on server side (I disabled client side).
The validation is inside a user control but doesn't seem to work. For
simplifying things I took out almost all code of the function that the
custom user control calls ( CustomValidator1_ServerValidate) when
clicking a button

protected void CustomValidator1_ServerValidate(object source,
ServerValidateEventArgs args)
{
args.IsValid = false;
}

When I click a button this function get called first but then goes to
the function that handles the buttonclick. I don't see why it stops
and returns an errorstate to the page?

Am I missing something?

Regards,
Stijn
 
If you don't use client validation (even if you do) you have to test for the
Page.IsValid == true on every postback, there fore in your button click event
handler add following condition .:

protected void btn_Click(object sender, EventArgs e)
{
if (IsValid) // on user / webserver controls use Page.IsValid
{
// do what you did before
}
}
 
Back
Top