CompareValidator no working on DropDown List

I have some cascading dropdown lists in an update panel plus another dropdown list that is in the update panel but does not get updated.  All the dropdowns have an intial value that says -- Choose <item> -- with a selected value of "".  I have RequiredFieldValidators and CompareValidators on all of the dropdown lists.  

When the page is first loaded, if I press the Submit button I am only getting the error message on the Title dropdown.  I am expecting the error to show on the Title and Division dropdowns.  Can someone review my markup to see what I may be doing wrong between the 2 dropdowns?

<!-- Division Dropdown markup -->
                        <asp:DropDownList ID="ddDivision" runat="server" CssClass="dropdownFormat" 
                            AppendDataBoundItems="True" CausesValidation="True" ClientIDMode="Static" 
                            AutoPostBack="true" OnSelectedIndexChanged="ddDivision_SelectedIndexChanged"
                            ToolTip="Employee's new Division if transferring to a new Division or Employee's current Division" >
                        </asp:DropDownList>
                        <asp:RequiredFieldValidator ID="ddDivisionValidator0" runat="server" 
                            ErrorMessage="Division is required" validationgroup="EmployeeInfo"
                            ControlToValidate="ddDivision"  Display="Static" Text="*" InitialValue='""'
                            BackColor="Red" Font-Bold="True" ForeColor="White" SetFocusOnError="true"></asp:RequiredFieldValidator>
<!-- RequiredFieldValidator isn't working so using CompareValidator to make sure a Division is selected -->
                        <asp:CompareValidator ID="CompareValidator2" runat="server"
                            ErrorMessage="Division is required" ValidationGroup="TransferInfo" Operator="Equal"
                            ControlToValidate="ddDivision" Display="Static" BackColor="Red" Font-Bold="True" 
                            ForeColor="White" SetFocusOnError="true" Text="*" ValueToCompare='""'></asp:CompareValidator>

<!-- Title Dropdown markup -->
                        <asp:DropDownList ID="ddTitle" runat="server" Width="200px" CssClass="dropdownFormat"
                            AppendDataBoundItems="True" CausesValidation="True"  ClientIDMode="Static"
                            ToolTip="Employee's new Title if being promoted as part of the transfer or Employee's current Title">
                        </asp:DropDownList>
                        <asp:RequiredFieldValidator ID="ddTitleValidator" runat="server" 
                            ErrorMessage="Title is required"  validationgroup="TransferInfo"
                            ControlToValidate="ddTitle"  Display="Static" Text="*" 
                            BackColor="Red" Font-Bold="True" ForeColor="White" SetFocusOnError="true"></asp:RequiredFieldValidator>

Open in new window


Rendered Code
<!-- Division Rendered Code -->
                        <select name="ctl00$ctl00$ctl00$dynamiccontainer$onebox$onebox$ddDivision" onchange="javascript:setTimeout(&#39;WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$ctl00$ctl00$dynamiccontainer$onebox$onebox$ddDivision&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, true))&#39;, 0)" id="ddDivision" title="Employee&#39;s new Division if transferring to a new Division or Employee&#39;s current Division" class="dropdownFormat">
		<option selected="selected" value="">-- Choose Division --</option>
		<option value="1">Division A</option>
		<option value="3">Division B</option>
		<option value="4">Division C</option>

	</select>
                        <span id="dynamiccontainer_onebox_onebox_ddDivisionValidator0" style="color:White;background-color:Red;font-weight:bold;visibility:hidden;">*</span>
<!-- RequiredFieldValidator isn't working so using CompareValidator to make sure a Division is selected -->
                        <span id="dynamiccontainer_onebox_onebox_CompareValidator2" style="color:White;background-color:Red;font-weight:bold;visibility:hidden;">*</span>

<!-- Title Rendered Code -->
                        <select name="ctl00$ctl00$ctl00$dynamiccontainer$onebox$onebox$ddTitle" id="ddTitle" title="Employee&#39;s new Title if being promoted as part of the transfer or Employee&#39;s current Title" class="dropdownFormat" style="width:200px;">
		<option selected="selected" value="">-- Choose Title --</option>
		<option value="7">ADMIN</option>
		<option value="8">AM</option>
		<option value="38">ANALYST</option>
		<option value="0">-- Not Listed --</option>
	</select>
                        <span id="dynamiccontainer_onebox_onebox_ddTitleValidator" style="color:White;background-color:Red;font-weight:bold;visibility:hidden;">*</span>

Open in new window


I've attached a copy of the screen showing what is displayed when Process Transfer is clicked.  Division - Title are in an Update Panel.  

Any help is greatly appreciated!
CompareValidator-Error.JPG
dyaroshAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DropZoneCommented:
If I am not mistaken, you are setting the value of the Division control with the "InitialValue" attribute to be different from the actual initial value of "blank."  You have this attribute set to ""--literally.  That's not an empty string, those are two double-quotes:  '""'.

You should remove this attribute entirely, the default is String.empty anyways.

    dZ.
0
dyaroshAuthor Commented:
I removed the attribute but it still doesn't validate the Division dropdown.  This is my current markup:

                        <asp:DropDownList ID="ddDivision" runat="server" CssClass="dropdownFormat"
                            AppendDataBoundItems="True" CausesValidation="True" ClientIDMode="Static"
                            AutoPostBack="true" OnSelectedIndexChanged="ddDivision_SelectedIndexChanged"
                            ToolTip="Employee's new Division if transferring to a new Division or Employee's current Division" >
                        </asp:DropDownList>
                        <asp:RequiredFieldValidator ID="ddDivisionValidator0" runat="server"
                            ErrorMessage="Division is required" validationgroup="EmployeeInfo"
                            ControlToValidate="ddDivision"  Display="Static" Text="*"
                            BackColor="Red" Font-Bold="True" ForeColor="White" SetFocusOnError="true"></asp:RequiredFieldValidator>
0
dyaroshAuthor Commented:
I just tried to use a CompareValidator and it didn't work either even though it worked on another control.  The difference is the Division dropdown is inside an UpdatePanel and the other dropdown is outside the Update Panel.  Could this be the problem?
0
dyaroshAuthor Commented:
I discovered my problem.  I used a different value for the validationgroup property than what I was using in the validation summary and on the submit button.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dyaroshAuthor Commented:
I changed the validationgroup property on the dropdown control to match the name used in the ValidationGroup property of the ValidationSummary and also on the Submit button.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.