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

confirm on selecting item

2 Answers 119 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Benjamin
Top achievements
Rank 1
Benjamin asked on 11 Jun 2009, 03:28 AM
Hi,

I want to show one confirmation message on changing the combobox item for only one particlar item. I want to cancel the selection if clicked on cancel. Can i do this on client side using javascript? any help is appreatiated.

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 11 Jun 2009, 05:04 AM
Hi,

Try out the following client side code.

aspx:
 
<telerik:RadComboBox ID="RadComboBox2" runat="server" OnClientSelectedIndexChanging="OnClientSelectedIndexChanging"
    <Items> 
        <telerik:RadComboBoxItem Text="Text1" Value="Value1"></telerik:RadComboBoxItem> 
        <telerik:RadComboBoxItem Text="Text2" Value="Value2"></telerik:RadComboBoxItem> 
        <telerik:RadComboBoxItem Text="Text3" Value="Value3"></telerik:RadComboBoxItem> 
    </Items> 
</telerik:RadComboBox> 

JavaScript:
 
<script type="text/javascript"
function OnClientSelectedIndexChanging(sender, args) 
    if((args.get_item().get_text()=="Text3") && !confirm('Do you want to change selection to Item3')) 
    {         
        args.set_cancel(true); 
    } 
</script> 
Checkout the following links for more information about client side methods and events of RadComboBox:
RadComboBox object
Client-Side Events

Thanks,
Shinu.
0
Benjamin
Top achievements
Rank 1
answered on 11 Jun 2009, 06:20 PM
Thanks shinu. it worked. Thanks for the links.
Tags
ComboBox
Asked by
Benjamin
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Benjamin
Top achievements
Rank 1
Share this question
or