Instead of performing the check-box functionality on button click you could use the OnCheckedChanged event of the check-box and set AutoPostBack to true, in ASP.NET. Then you will can execute the check-box actions automatically and perform the data validation on the button click event.
(WinForms)
private void checkbox1_CheckedChanged(object sender, EventArgs e)
{
//Execute method
}
(ASP.NET)
<asp:CheckBox ID="checkbox" runat="server" OnCheckedChanged="checkbox_OnCheckedChanged" AutoPostBack="true" />
private void checkbox_OnCheckedChanged(object sender, EventArgs e)
{
//Execute method
}
Button Click Event
protected void button_onclick(object sender, EventArgs e)
{
if (!checkbox1.Checked || !checkbox2.Checked)
MessageBox.Show("Error");
}