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?

\$\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)

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.