Solved

Validate DropDownList with CascadingDropdown

Posted on 2010-09-08
5
1,188 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

All of the resources available today make learning a new digital media easier than ever-- if you know where to begin. This is a clear, simple guide to a few of the basic digital art mediums and how to begin learning them on your own.
Invest in your employees with these five simple steps to improve employee engagement and retention.
This video demonstrates basic masking and how to edit the mask to reveal the desired image.
XMind Plus helps organize all details/aspects of any project from large to small in an orderly and concise manner. If you are working on a complex project, use this micro tutorial to show you how to make a basic flow chart. The software is free when…

739 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