title: Multiple Validation Groups in c#
body: <p>I have two validation groups: Group1 and Group2</p>
  
  <p>I have an save button that needs to validate all validation groups.</p>
  
  <p>But how can it be done server side?</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
       &lt;form runat="server"&gt;
            &lt;asp:textbox id="TextBox1" runat="server"/&gt;
            &lt;asp:requiredfieldvalidator ValidationGroup="Group1"
                                                         ErrorText="Need to Fill in Value 1  !"
                                                         ControlToValidate="TextBox1"
                                                         runat="server"/&gt;
              &lt;asp:textbox id="TextBox2" runat="server"/&gt;
  
              &lt;asp:requiredfieldvalidator ValidationGroup="Group2"
                                                           ErrorText="Need to Fill in Value 2 !"
                                                           ControlToValidate="TextBox2"
                                                           runat="server"/&gt; 
  
              &lt;asp:button text="Group1" ValidationGroup="Group1" runat="server"/&gt;
              &lt;asp:button text="Group2" ValidationGroup="Group2" runat="server"/&gt;
  
             &lt;asp:ImageButton ID="Save" runat="server" OnClick="Save_Click"
              ImageUrl="/aspnet/Img/save_button.gif" 
              CommandArgument="Save"
              OnClientClick="if (!confirm('Are you sure?')) return false;" /&gt;
       &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>#First Edit</strong></p>
  
  <pre><code>protected void Save_Click(object sender, ImageClickEventArgs e)
  {
      Page.Validate("Group1");
      Page.Validate("Group2");
  
      if (Page.IsValid)
      {
          //validate page
      }
      else
      {
          Page.ClientScript.RegisterStartupScript(this.GetType(), "Msg", "alert('Stop.');", true);
      }
  }
  </code></pre>