1
\$\begingroup\$

I have 2 validation groups, VG1 and VG2. I have a button BtnInsert that saves data into Datasource. Its Validation Group is VG2. Now, I want to validate both VG1 and VG2 when a user clicks the BtnInsert.

protected void BtnInsert_click(object sender,EventArgs e)
{
 // validate VG1
 Page.Validate("VG1");
 // Page.Validate("VG2") is not required as BtnInsert is of that group
 if(Page.IsValid)
 {
 // call insert function
 } 
}

Is this code right, and by clicking BtnInsert, both groups are validated?

Jamal
35.2k13 gold badges134 silver badges238 bronze badges
asked Feb 7, 2012 at 13:12
\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

AFAIK, you won't get client-side validation of VG2, but otherwise I can't see that it shouldn't work. (There is probably a client-side event and a method you could call to duplicate the behavior for the client)

answered Feb 9, 2012 at 11:16
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.