custom validation

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
 
G

Guest

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
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top