validation summary problem with dropdown

Posted by Amar888 under Regular Expressions on 4/22/2010 | Views : 3847 | Status : [Member] | Replies : 2
in my form i am using validation summary , but it not applicable to dropdown i mean it's not firing .If any one know pls send me solution


Posted by: SurajRane on: 4/23/2010 [Member] Starter


Refer following code. If you are using Dropdown list. its first item is always selected. hence RFV do not fire for it. if you want to fire it in such situation then set "InitialValue" property of RFV to default selected Item.

<asp:ValidationSummary ID="ValidationSummary1" runat="server" ValidationGroup="Group1" />

<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem Text="Item1" Value="Item1" Selected="False"></asp:ListItem>
<asp:ListItem Text="Item2" Value="Item2"></asp:ListItem>
<asp:ListItem Text="Item3" Value="Item3"></asp:ListItem>

<asp:RequiredFieldValidator InitialValue="Item1" ID="RequiredFieldValidator1" runat="server" ErrorMessage="RequiredFieldValidator"
ValidationGroup="Group1" ControlToValidate="DropDownList1"></asp:RequiredFieldValidator>
<asp:Button ID="Button1" runat="server" Text="Click Me to Validate" ValidationGroup="Group1" />

Mark as answer if satisfied

Amar888, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 4/23/2010 [Member] [MVP] [Administrator] NotApplicable

Good Morning Amar888

as SurajRane demonstrated, the Validation Summary will not show you anything if the Property Error Message does not have any warning or string. The Error Message Property is used if you want to use the Validation Summary and the Text Property is used if you want to display the Error near the control.

When using Validation Summary Control this is use full

and the Text Property when you want to display the message near the control.

Thank you for posting at DotnetFunda

Vuyiswa Maseko

Thank you for posting at Dotnetfunda

Amar888, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response