Solved

Validate DropDownList with CascadingDropdown

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

The article will include the best Data Recovery Tools along with their Features, Capabilities, and their Download Links. Hope you’ll enjoy it and will choose the one as required by you.
This article discusses how to create an extensible mechanism for linked drop downs.
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 the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

809 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