Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
280
Using asp:RequiredFieldValidator for ig:WebDropDown
posted

I have a ig:WebDropDown which is having the starting value as 'Select' as below

 

 

 

<ig:WebDropDown ID="ddlTeam" runat="server" Width="260px" DisplayMode="DropDownList">

 

 

</ig:WebDropDown>

I used RequiredFieldValidator for the control as below,

 

 

<

 

asp:RequiredFieldValidator ID="rfvEmployee" runat="server" InitialValue="Select"

 

 

 

ErrorMessage="Select a Team" ControlToValidate="ddlTeam">

The problem is when i have value as 'Select' in WebDropDown and click on some button,

the validation fired correctly and after selecting some other value other than 'Select' in WebDropDown

and the Validation Message is not going off, still its showing as 'Select a Team'

What i came to know is only when some post back is happening then only the Validation is working

fine, becoz when i set AutoPostBack = true for WebDropDown its working.

 

But i dont want to set AutoPostBack = true.

So, can you provide a solution for this ASAP, how to use RequiredFieldValidator for ig:WebDropDown without using

AutoPostBack to true.

 

---------------------------

Thanks in Advance.

Pavan. 

Parents
No Data
Reply
  • 24671
    Suggested Answer
    posted

    You don't need to set AutoPostBack to true. the asp:RequiredFieldValidatior works fine without a postback, please have a look at the attached sample. 

     

    Check out the following code:

     

        <form id="form1" runat="server">

     

            <asp:ScriptManager ID="ScriptManager1" runat="server">

            </asp:ScriptManager>

            <ig:WebDropDown ID="WebDropDown1" runat="server" Width="200px" EnableAutoFiltering="Off"  DisplayMode="DropDownList">

                <Items>

                     <ig:DropDownItem Selected="False" Text="Select" Value="">

                    </ig:DropDownItem>

                    <ig:DropDownItem Selected="False" Text="DropDown Item" Value="">

                    </ig:DropDownItem>

                    <ig:DropDownItem Selected="False" Text="DropDown Item" Value="">

                    </ig:DropDownItem>

                    <ig:DropDownItem Selected="False" Text="DropDown Item" Value="">

                    </ig:DropDownItem>

                    <ig:DropDownItem Selected="False" Text="DropDown Item" Value="">

                    </ig:DropDownItem>

                </Items>

            </ig:WebDropDown>

            <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator1" ControlToValidate="WebDropDown1" InitialValue="Select" ErrorMessage="Please select something "></asp:RequiredFieldValidator>

    <asp:Button runat="server" Text="Submit the Form" />

        </div>

        </form>

     

    Hope this helps,

    Angel 

Children
No Data