Dropdown list validationMAMinnu Merin Alex10yAsked Oct 3, 2016, 1:15 AM EDT6 answersShareLinkedInXCopy linkSaveC# code to give requiored field validation to a dropdown list
Dropdown list validationMAMinnu Merin Alex10yAsked Oct 3, 2016, 1:15 AM EDT6 answersShareLinkedInXCopy linkSaveC# code to give requiored field validation to a dropdown list
Ravi PatelRank #439 · 5.7K reputation10y agoPosted Oct 3, 2016, 1:26 AM EDT0Hi ,refer the bellow linkhttp://stackoverflow.com/questions/5310609/dropdownlist-validation-in-asp-net-using-required-field-validatorhttp://www.aspsnippets.com/Articles/Validate-Check-HTML-Select-DropDownList-using-JavaScript-and-jQuery.aspx0
MAMinnu Merin Alex188 reputation10y agoPosted Oct 3, 2016, 1:40 AM EDT0i saw this link before , and i have tried it but its not working0
Midhun TpRank #388 · 6.5K reputation10y agoPosted Oct 3, 2016, 3:43 AM EDT0Hi,Please try like below. You should give value as empty string in dropdowns first option for validation to work - CausesValidation="True" CssClass="fontStandardInput"> Value=""> Display="Dynamic" CssClass="fontValidation" SetFocusOnError="true" ErrorMessage="Select from the list.">0Rajeesh MenothRank #118 · 18.4K reputation10y agoPosted Oct 3, 2016, 4:41 AM EDT0Hi, First see the Dropdownlist<asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="True"> <asp:ListItem>--Select--asp:ListItem> <asp:ListItem>Penasp:ListItem> <asp:ListItem>Pencilasp:ListItem> <asp:ListItem>Rubberasp:ListItem> asp:DropDownList> Then for validate see the requiredfield validator In RequiredFieldValidator have contain the property ControlToValidate there you need to mention your drop down id.<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="DropDownList1" ErrorMessage="Value Required!" InitialValue="--Select--">asp:RequiredFieldValidator> <asp:Button ID="Button1" runat="server" Text="Button" /> div> You must set InitialValue property of the RequiredFieldValidator with theat InitialValue match with DropDownList InitialValue. Reference : http://www.c-sharpcorner.com/blogs/asp-net-dropdownlist-validation-using-required-field-validation1 0Delpin Susai RajRank #53 · 29.5K reputation10y agoPosted Oct 3, 2016, 8:47 AM EDT0CodeCopy0Bikesh SrivastavaRank #108 · 20.3K reputation10y agoPosted Oct 3, 2016, 7:16 PM EDT0Hi,Use this code to resolve your problem."-1"ID="Req_ID"Display="Dynamic"ValidationGroup="g1"runat="server"ControlToValidate="ControlID"Text="*"ErrorMessage="ErrorMessage">0Join to answer this questionEvery answer you publish earns 20 SHARP.Create free accountSign inKnow the answer?Answer a question in the forums and earn +20 SHARP for every answer.See unanswered questionsForumsTop experts01Arun PottiAnswers in the forums20answers02Tahir AnsariAnswers in the forums5answers03Kamlesh KumarAnswers in the forums5answers04Sam HobbsAnswers in the forums4answers05Željko PerićAnswers in the forums3answers?YouYour name goes here.Every answer: 20 SHARP.JoinFull leaderboard →2026DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Rajeesh MenothRank #118 · 18.4K reputation10y agoPosted Oct 3, 2016, 4:41 AM EDT0Hi, First see the Dropdownlist<asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="True"> <asp:ListItem>--Select--asp:ListItem> <asp:ListItem>Penasp:ListItem> <asp:ListItem>Pencilasp:ListItem> <asp:ListItem>Rubberasp:ListItem> asp:DropDownList> Then for validate see the requiredfield validator In RequiredFieldValidator have contain the property ControlToValidate there you need to mention your drop down id.<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="DropDownList1" ErrorMessage="Value Required!" InitialValue="--Select--">asp:RequiredFieldValidator> <asp:Button ID="Button1" runat="server" Text="Button" /> div> You must set InitialValue property of the RequiredFieldValidator with theat InitialValue match with DropDownList InitialValue. Reference : http://www.c-sharpcorner.com/blogs/asp-net-dropdownlist-validation-using-required-field-validation1 0
Bikesh SrivastavaRank #108 · 20.3K reputation10y agoPosted Oct 3, 2016, 7:16 PM EDT0Hi,Use this code to resolve your problem."-1"ID="Req_ID"Display="Dynamic"ValidationGroup="g1"runat="server"ControlToValidate="ControlID"Text="*"ErrorMessage="ErrorMessage">0
Ravi PatelRank #439 · 5.7K reputationPosted Oct 3, 2016, 1:26 AM EDT
Minnu Merin Alex188 reputationPosted Oct 3, 2016, 1:40 AM EDT
Midhun TpRank #388 · 6.5K reputationPosted Oct 3, 2016, 3:43 AM EDT
Rajeesh MenothRank #118 · 18.4K reputationPosted Oct 3, 2016, 4:41 AM EDT
Delpin Susai RajRank #53 · 29.5K reputationPosted Oct 3, 2016, 8:47 AM EDT
Bikesh SrivastavaRank #108 · 20.3K reputationPosted Oct 3, 2016, 7:16 PM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts