Assume that we have two
separate set of designs in the same webpage like
Create a new webpage
Design the webpage
Set
the following properties for RequiredFieldValidator2:-
ID --- RF1ControlToValidate --- Enter UserNameText --- Enter Password
Set
the following properties for RequiredFieldValidator2:-
ID --- RF2ControlToValidate --- txtUserNameText --- Enter Password
Set
the following properties for RequiredFieldValidator2:-
ID --- RFControlToValidate --- txtHTNumText --- Enter HallTicket Number
protected
void btnLogin_Click (object
sender, EventArgs e)
{
lblDisplay.Text = "Login Successfull";
}
protected void btnSubmit_Click (object
sender, EventArgs e)
{
lblDisplay.Text = "Fail";
}
|
- In the above Example when user clicks on login by entering UserId, Password.
- It also will ask the user to enter Hall Ticket Number at the same time when user is entering Hall Ticket Number and clicks on Submit Button. It also will ask user to enter UserName and Password. But this should not happen.
- To overcome this drawback we use “Validation Group” Property
- when we set “Validation Group” common validations are performed to the same group .
- select RF1 & RF2& Login Button set Validation Group as “V1”
- Select the Controls “RF3&Submit” Button set validation group as “V2”.
- Now when user clicks on Login Button only “RF1 & RF2” will be executed and “RF3” will not be executed.
- Whenever user clicks on Submit Button only “RF3” will be executed, “RF1 & “RF2” will not be executed.
- Run the Application and Check.
No comments:
Post a Comment