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?