Custom validatior in ASP.net
Posted
by DJPB
on Stack Overflow
See other posts from Stack Overflow
or by DJPB
Published on 2010-04-12T14:51:52Z
Indexed on
2010/04/22
12:13 UTC
Read the original article
Hit count: 211
Hi there. I'm working on an ASP.NET/C# app.
I have 2 text boxes and I need to validate if the input text for both of them are not both null ex:
if(string.IsNullOrEmpty(TextBox1.Text) && string.IsNullOrEmpty(TextBox2.Text) )
//FAIL!!!
else
// OK!
that is, at least one txtBox has values
I was planning on using a custom validator but it seems that the validation function only gets called when something is written on the textBox i'm using has the 'control to validate'. Now, that doesn't work for me since I want to show an error message when both text boxes are empty. Is there a way to make the validation function to be called with, for example a postback? Or is there any other better approach to this case than the custom validator?
tks
© Stack Overflow or respective owner