Yasemin Boy Ertan
Yasemin Boy Ertan

Reputation: 85

validation control in asp.net with masterpage buttons

I have a lot of textboxes on submit page and all have a validator. I want to control them with a submit button which is on master page. It works but other buttons also cause validation. validation summary is always shown either submit button is clicked or any other buttons. how can I control this situation? (asp.net)

Upvotes: 0

Views: 1406

Answers (2)

Ashwini Verma
Ashwini Verma

Reputation: 7525

for each individual submit use "ValidationGroup". here is the sample:

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ControlToValidate="TextBox1" ValidationGroup="Submit" ID="RequiredFieldValidator1" runat="server" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ControlToValidate="TextBox2" ValidationGroup="Submit" ID="RequiredFieldValidator2" runat="server" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
<asp:Button ID="Button1" ValidationGroup="Submit" runat="server" Text="Button" />

Upvotes: 2

Deepu Madhusoodanan
Deepu Madhusoodanan

Reputation: 1505

I think you can resolve this by using ValidationGroup Property..

http://msdn.microsoft.com/en-us/library/ms227424.aspx

http://www.w3schools.com/aspnet/prop_webcontrol_imagebutton_validationgroup.asp

Thanks

Deepu

Upvotes: 0

Related Questions