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

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.