views:

49

answers:

1

hi, i am using asp.net validators for validating simple fields like blank textboxes (e.g. login page). my problem is when i am submitting blank fields,the validators are giving correct output. and in second step, when i entered incorrect username the label where i have given error message of username is getting displayed along with blank validation message of validators.

means along with label which is visible=false by default is getting true even if there is blank field.

i wrote all .cs code in if (Page.IsValid) { }

+2  A: 

You can use RequiredFieldvalidator for the blank fields. You set the ControlToValidate property to the id of the control you wish to validate

<asp:RequiredFieldValidator runat="server"
    id="ReqFldVal1" ControlToValidate="TextBox1" />
Carlos Muñoz
also you may use Page.Validate() method in code to validate page against the validators on page...
dankyy1