Note that there are some explanatory texts on larger screens.

plurals
  1. PODefault Button not working with multiple validation groups
    text
    copied!<p>Thank you very much for taking the time to read this. I have an issue in which I was setting a default button for an ASP.NET page on page load from code behind, but now that I have multiple validation groups targeting one control, that is no longer working. Now, when I hit enter while in that control (textbox), validation for both groups are triggered minus the validation summary text.</p> <p>Here is my examplefied code:</p> <p>ASPX</p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;td&gt;&lt;asp:Textbox runat="server" ID="validateMe"&gt;&lt;/asp:TextBox&gt;&lt;/td&gt; &lt;td&gt;&lt;asp:RequiredFieldValidator ID="firstValidator" runat="server" ErrorMessage="First check not valid" Text="*" ControlToValidate="validateMe" ValidationGroup="firstGroup"&gt;&lt;/asp:RequiredFieldValidator&gt; &lt;td&gt;&lt;asp:RequiredFieldValidator ID="secondValidator" runat="server" ErrorMessage="Second check not valid" Text="*" ControlToValidate="validateMe" ValidationGroup="secondGroup"&gt;&lt;/asp:RequiredFieldValidator&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;asp:Button runat="server" ID="firstButton" Text="V1" ValidationGroup="firstGroup"/&gt;&lt;/td&gt; &lt;td&gt;&lt;asp:Button runat="server" ID="secondButton" Text="V2" ValidationGroup="secondGroup"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;table&gt; &lt;asp:ValidationSummary ID="firstSummary" runat="server" ValidationGroup="firstGroup"/&gt; &lt;asp:ValidationSummary ID="secondSummary" runat="server" ValidationGroup="secondGroup"/&gt; </code></pre> <p>C#</p> <pre><code>protected void Page_Load(object sender, EventArgs e) { this.Form.DefaultButton = firstButton.UniqueID; } </code></pre> <p>If I use this and hit 'Enter' while inside of the textbox without typing anything into it, then neither of the validation summaries will appear but I will have two asterisks next to the textbox (one for each group). If the user presses 'Enter' I would expect a full validation using only the first group which is supposed to be assigned to the DefaultButton (here, 'firstButton'). Is there any way to achieve this functionality and initiate the client-side validation that would have happened had the user clicked 'firstButton' instead?</p> <p>I have also tried wrapping the whole table plus the validation summaries inside of an asp:Panel and setting the DefaultButton there, but I received the same results. Any help or pointers in the right direction would be greatly appreciated!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload