Solved

Validate DropDownList with CascadingDropdown

Posted on 2010-09-08
5
1,173 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
This video demonstrates basic masking and how to edit the mask to reveal the desired image.
This video demonstrates how to use each tool, their shortcuts, where and when to use them, and how to use the keyboard to improve workflow.

948 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

18 Experts available now in Live!

Get 1:1 Help Now