This is a migrated thread and some comments may be shown as answers.

combobox dropdown does not open with OnClientSelectedIndexChanged method

0 Answers 92 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
vishesh kumar
Top achievements
Rank 1
vishesh kumar asked on 26 Mar 2010, 05:36 AM
Hi,
I have a rad combobox and i need to make a textbox as a required field if a particular item was selected in the combobox.

I have the following code:
<td valign="top" style="font-weight: normal" class="ms-formbody"
                <%-- <asp:DropDownList ID="ddlReferralSource" runat="server" Width="132"
                </asp:DropDownList>--%> 
                <telerik:RadComboBox runat="server" ID="radComboReferralSource" AllowCustomText="false" 
                    EnableLoadOnDemand="false" MarkFirstMatch="true" OnClientSelectedIndexChanged="ValidateHearAboutUsSource" > 
                </telerik:RadComboBox> 
                <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator2" ControlToValidate="radComboReferralSource" 
                    Display="Dynamic" SetFocusOnError="true" ErrorMessage="<%$Resources:CareerResources, Career_RequiredField%>" 
                    ValidationGroup="profile" InitialValue="<%$Resources:CareerResources, Career_SelectText%>"></asp:RequiredFieldValidator> 
            </td> 
            <td> 
                <asp:TextBox runat="server" ID="txtHearAboutUsSourceValue"></asp:TextBox> 
                 <asp:RequiredFieldValidator runat="server" ID="rfvHearAboutUsSourceValue" ControlToValidate="txtHearAboutUsSourceValue" 
                    Display="Dynamic" SetFocusOnError="true" ErrorMessage="<%$Resources:CareerResources, Career_RequiredField%>" 
                    ValidationGroup="profile" ></asp:RequiredFieldValidator> 
            </td> 

as soon as i add the OnClientSelectedIndexChanged attribute, the dropdown doesnt even open on the page.
so i have two questions:
  1. How to solve the problem with dropdown in the rad combobox?
  2. How to force client side validation for a particular textbox if a particular value is selected in the radcombobox?

Update: I am now able to view the dropdown values but they are not triggering the ValidateHearAboutUsSource function.
<script type="text/javascript" language="javascript"
        function ValidateHearAboutUsSource(item, eventArgs) { 
alert("test"); 
        var item1 = eventArgs.get_item(); 
        alert("You selected " + item1.get_text()); 
            var dropdownvalue = item.value; 
            alert(dropdownvalue); 
            var textBoxItem = document.getElementById('<%=txtHearAboutUsSourceValue.ClientID%>
            var validator = document.getElementById('<%=rfvHearAboutUsSourceValue.ClientID%>'); 
        } 
    </script> 

Thanks
Vishesh

No answers yet. Maybe you can help?

Tags
ComboBox
Asked by
vishesh kumar
Top achievements
Rank 1
Share this question
or