javascript and combo boxes
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('e开发者_如何学编程ric');
}
<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?
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>
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.
精彩评论