Question

This is the issue I have going right now with validation controls and I simply can't find answer anywhere for it.

I currently have a required field validator watching a listbox. The validator's initial value property is set to "None". The first item in the listbox's value is also set to "None", thus forcing the user to change the selection. However I don't want the validation to show on the selected index change, I want it to show after a button press. So I changed the validation group of the validator and the button to "final" however the validator still shows on selected index changed without the button being pressed.

My code on the validator:

<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
ErrorMessage="Please Select an Incident" ControlToValidate="lstIncidents" 
ValidationGroup="final" CssClass="style3" InitialValue="None" Display="Dynamic">
</asp:RequiredFieldValidator>

My Code on the Submit Button:

<asp:Button ID="btnSubmit" runat="server" Text="Submit" ValidationGroup="final" 
Enabled="False" />

Anyone see what might be wrong here?

Thanks in advance!

Was it helpful?

Solution

Set the validator's EnableClientScript to false (default is true):

<asp:RequiredFieldValidator EnableClientScript="False" ID="RequiredFieldValidator2" runat="server" 
ErrorMessage="Please Select an Incident" ControlToValidate="lstIncidents" 
ValidationGroup="final" CssClass="style3" InitialValue="None" Display="Dynamic">
</asp:RequiredFieldValidator>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top