Solved

Validate DropDownList with CascadingDropdown

Posted on 2010-09-08
5
1,172 Views
Last Modified: 2013-12-13
I can't get this to validate. The same works for my regular DDLs without cascadingdropdown extenders. But this one will not work. I tried to set controltovalidate="CascLessonDay" but it is not recognized at run time as a control that can be validated.

the other thing is, is that this is within a createNewUser wizard control, and it is hard to access the next button for me, so I dont' know how to validate this ddl to make sure that the user selects something.

Thank you.
<asp:DropDownList ID="LessonDay" runat="server" >

                    </asp:DropDownList>



<asp:CascadingDropDown ID="CascLessonDay" ParentControlID="Teacher1" Category="day2"

       PromptText="Select Day"

        ServiceMethod="GetDay"

         ServicePath="~/Teachers.asmx"

          TargetControlID="LessonDay" runat="server">

                </asp:CascadingDropDown>



       <asp:CompareValidator ID="CompareValidator1" ControlToValidate="LessonDay" Operator="notEqual" ValueToCompare="0" ErrorMessage="Please select day" runat="server">*</asp:CompareValidator>

Open in new window

0
Comment
Question by:mlg101
  • 2
  • 2
5 Comments
 
LVL 2

Expert Comment

by:bureshd
ID: 33633609
use a Required Field Validator instead.

<asp:requiredfieldvalidator ID="ReqVal" runat="server"   errormessage="RequiredFieldValidator" InitialValue="0" ControlToValidate="LessonDay" ErrorMessage="Please select day"></asp:requiredfieldvalidator>

Open in new window

0
 
LVL 1

Author Comment

by:mlg101
ID: 33633691
That does not work either. When I click the button, it just goes to the next page without any selection
0
 
LVL 2

Expert Comment

by:bureshd
ID: 33633714
set the button and validator with the same validator group....and make sure the button cause validation
<asp:requiredfieldvalidator ID="ReqVal" runat="server"   errormessage="RequiredFieldValidator" InitialValue="0" ControlToValidate="LessonDay" ErrorMessage="Please select day" ValidationGroup="check"></asp:requiredfieldvalidator>

Open in new window

0
 
LVL 1

Author Comment

by:mlg101
ID: 33633729
I can't find the "next" button in the createuserwizard...where is it?
0
 
LVL 15

Accepted Solution

by:
rajeeshmca earned 500 total points
ID: 33633828
Hi mlg101,

Add the PromptValue property for the Cascading dropdown control...

<asp:CascadingDropDown ID="CascLessonDay" ParentControlID="Teacher1" Category="day2"
                PromptText="Select Day" PromptValue="0" ServiceMethod="GetDay" ServicePath="~/Teachers.asmx"
                TargetControlID="LessonDay" runat="server">
            </asp:CascadingDropDown>
            <asp:CompareValidator ID="CompareValidator1" ControlToValidate="LessonDay" Operator="NotEqual"
                ValueToCompare="0" ErrorMessage="Please select day" runat="server" >*</asp:CompareValidator>

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
The viewer will learn how to create multiple layers to apply various filters and how to delete areas from each layer’s filter.
The viewer will learn how to successfully download and install the SARDU utility on Windows 8, without downloading adware.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now