views:

189

answers:

2

I have a combo box in a Form View and onchange i want to access a javascript function just as i'd normally do any drop down list. However, it doesn't seem to be even getting to the function

function Showused()
 {
 alert('eric');
 }



 <telerik:RadComboBox ID="RadComboBoxProvided" onchange="javascript: Showused();"  runat="server" Width="50px" >
                                            <Items>
                                                <telerik:RadComboBoxItem runat="server" Text="Yes" Value="Y"  /> 
                                                <telerik:RadComboBoxItem runat="server" Text="No" Selected="true" Value="N"  /> 
                                            </Items>

</telerik:RadComboBox>

Simple javascript call. Any idea why this doesn't work?

+2  A: 

is not a combo box, it is a custom tag, that will convert itself to an HTML combo box, to be sure what is happening there, run your server and go to that page, and then right click on the page in your browser and look at the HTML source, and finally try to locate that combo box and see how it is really rendered.

Omar Al Kababji
it is shown as a div tag with class = "RadComboBox.."
Eric
and is there any track where the onchange event was written? may be you have to consult the documentation of that tag <telerik:RadComboBox> to understand how it should be used exactly.
Omar Al Kababji
+3  A: 

Hi,

The client-side event names are different for Telerik controls. The RadComboBox event for selected index changed (assuming you're using a recent version of the controls) is OnClientSelectedIndexChanged

You may want to consult the client-side programming guide for RadComboBox, or the list of client-side events.

Here's a sample for use with your example:

Javascript:

function SelectedIndexChanged(sender, eventArgs) {
   var item = eventArgs.get_item();
   alert("You selected " + item.get_text());
}

Markup:

<telerik:RadComboBox ID="RadComboBoxProvided" OnClientSelectedIndexChanged="SelectedIndexChanged" runat="server" Width="50px" >
    <Items>
        <telerik:RadComboBoxItem runat="server" Text="Yes" Value="Y"  /> 
        <telerik:RadComboBoxItem runat="server" Text="No" Selected="true" Value="N"  /> 
    </Items>
</telerik:RadComboBox>
KP
that makes since to me, but i've called that function onclientselectedindexchanged and it still didn't work.
Eric
you need to make sure your script signature matches. You have to have `function MyFunctionName(sender, eventArgs){}` and your `OnClientSelectedIndexChanged="MyFunctionName"` cannot have things like `javascript:MyFunctionName();` etc. it must be only the 'name' of the function - no parameters, braces, brackets etc.
KP
If it still doesn't work, what version of RadComboBox are you using? I've been using RadControls for about 4 years and can tell you the above should work for the more recent versions...
KP
Thanks alot Kevin. +1 also!
Eric