Here is my ASP.NET code. Simple. it has a A textbox associated with a required field validator and a submit button.
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="TextBox1" Display="Dynamic"
ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
<asp:Button ID="Button1" runat="server" Text="Click Me" />
Do the following
-
Click on Button1
-
RequiredFieldValidator will be shown
-
Type some text in TextBox
-
Use your Mouse(no tab please). and click on the button , you can see that your page does not “POSTBACK” and only the validation gets cleared. you need to
click again the button for Submission of Form.
This seems to be a bug by Microsoft when setting the property Display =”Dynmaic” and Is there a easy workaround without changing the intended behavior for
this available? I couldn’t find a solution for this anywhere.
Your page does not submit because the button moves away under the mouse when you want to click it. This is because it gets focus and the Validator-ErrorMessage disappears to the left.
If you insert a
<br/>in front of the button it works.Normally i use * as Text and use a ValidationSummary to display the ErrorMessage(s):
Or, if using ASP.Net Ajax, you could use nifty controls like the ValidatorCalloutExtender.