Asp-netASP.net BackEnd Programming 

How to Use Multiple Forms in Single Page Using ValidationGroup

I was using a bootstrap modal to 2 different forms in Single aspx page. Here the Problem was there was 2 forms so obviously 2 buttons are there, and i have used asp validation also so there was a conflict between the 2 buttons to validate and submit the form.

When i click Button1 it was validating the other buttons text field also. so to overcome from that use i got a solution From “ValidationGroup” Keyword, add this to all the asp input fields and button, group them as given below.

<%-- Group One --%>
<asp:TextBox ID="TextBox1" runat="server"
    ValidationGroup="One" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
    runat="server"
    Display="Dynamic"
    ValidationGroup="One"
    ControlToValidate="TextBox1"
    Text="Textbox one is required." />
<asp:Button runat="server" ID="Button1"
    OnClick="Button1_Click"
    Text="Submit"
    ValidationGroup="One" />
<hr/>
<%-- Group Two --%>            
<asp:TextBox ID="TextBox2" runat="server"
    ValidationGroup="Two" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator2"
    runat="server"
    Display="Dynamic"
    ValidationGroup="Two"
    ControlToValidate="TextBox2"
    Text="Textbox two is required.." />
<asp:Button runat="server" ID="Button2"
    OnClick="Button2_Click"
    Text="Submit"
    ValidationGroup="Two" />

By using ValidationGroup You have to Group the Text fields.

 

Also Read:  Integration sendinblue Transactional Email using Python

Related posts