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

Stop Postback clientside on Rad ComboBox

4 Answers 439 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Yash
Top achievements
Rank 1
Yash asked on 20 Jul 2008, 03:16 PM
Hi,
I'm new to Telerik controls and I'm quite enjoying it!

Right now, I'm facing a problem which I really hope someone could help me solve :)

I'm trying to use javascript to stop the postback when selecting an item in a RadComboBox whose AutoPostBack is true..., while still allowing the selected item in the combo box to change...

So from what I understood in the documentation, I can stop it using "return false" in ClientSelectedIndexChanging, but that is not working...

I wrote a test page to check whether the problem was specific to my application, but here also it does not work...

What am I doing wrong?

Thanking you before hand,
Cheers,
¥@$#.

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %> 
 
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml"
<head runat="server"
    <title>Test Page</title> 
    <script type="text/javascript"
        function check(item) 
        { 
            alert('test'); 
            return false; 
        } 
    </script> 
</head> 
<body> 
    <form id="form1" runat="server"
    <div> 
        <asp:ScriptManager ID="ScriptManager1" runat="server"
        </asp:ScriptManager> 
        <telerik:RadComboBox ID="RadComboBox1" Runat="server"  
            onclientselectedindexchanging="check"  
            onselectedindexchanged="RadComboBox1_SelectedIndexChanged1"  
            AutoPostBack="True" > 
            <Items> 
                <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem1" Value="1" /> 
                <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem2" Value="2" /> 
                <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem3" Value="3" /> 
                <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem4" Value="4" /> 
                <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem5" Value="5" /> 
            </Items> 
            <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
        </telerik:RadComboBox> 
        <br /> 
        <br /> 
        <br /> 
     
    </div> 
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
    </form> 
</body> 
</html> 
 

4 Answers, 1 is accepted

Sort by
0
Yash
Top achievements
Rank 1
answered on 21 Jul 2008, 03:11 AM
Ok I managed to make my way round the problem.

I don't know if it's the way to do things, but it seems to be working...

I changed the AutoPostBack to false on the combo box, and did the postback from javascript when required instead of doing the reverse...

Cheers,
¥@$#
0
Rosi
Telerik team
answered on 21 Jul 2008, 06:53 AM
Hello Yash,

You use RadComboBox for ASP.NET AJAX, so the correct way to stop the postback is:

function OnClientSelectIndexChanging(sender,eventarqs)  
{  
 
    eventarqs.set_cancel(true);  
 

I suggest you read more about client side of RadCombobox here.

You can check this code library as well: RadComboBox - Allow only certain items to postback

Regards,
Rosi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Neeraj Jain
Top achievements
Rank 1
answered on 11 Dec 2008, 05:52 PM
But above will also not let you change the value of combBox. In my project what I want is that Let user select the value but disable/enable postback depends on what they have selected. when I do this eventargs.set_cancel(true) it also revert the selected value of comboBox.
0
Simon
Telerik team
answered on 12 Dec 2008, 10:16 AM
Hello Neeraj Jain,

Please see this Code Library as it shows exactly how your goal can be achieved.

Best wishes,
Simon
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
ComboBox
Asked by
Yash
Top achievements
Rank 1
Answers by
Yash
Top achievements
Rank 1
Rosi
Telerik team
Neeraj Jain
Top achievements
Rank 1
Simon
Telerik team
Share this question
or