Cancel post back when calling "OnClientIndexChanged" event for RadComboBox

5 posts, 0 answers
  1. Tzach Kaufmann
    Tzach Kaufmann avatar
    95 posts
    Member since:
    Aug 2008

    Posted 25 Mar 2012 Link to this post

    Hi All,

    I want to cancel the post back when calling "OnClientIndexChanged" event.
    I tried to set AutoPostBack="false", but the page still posts back.
    I tried to cann eventArgs.set_cancel(true) for "OnClientIndexChanging", but then the client selection is not shown.

    How can I solve this problem?
    I just don't want the page to posts back...

    Thanks for your help..
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 26 Mar 2012 Link to this post

    Hello,

    I tried your scenario and and it works without postback. RadComboBox postbacks only if its AutoPostBack property is set to true. Following is the sample code.
    ASPX:
    <telerik:RadComboBox ID="RadComboBox1" runat="server" OnClientSelectedIndexChanged="OnClientSelectedIndexChanged" >
     <Items>
      <telerik:RadComboBoxItem Text="RadComboBoxItem1" />
      <telerik:RadComboBoxItem Text="RadComboBoxItem2" />
      <telerik:RadComboBoxItem Text="RadComboBoxItem3" />
      <telerik:RadComboBoxItem Text="RadComboBoxItem4" />
      <telerik:RadComboBoxItem Text="RadComboBoxItem5" />
      <telerik:RadComboBoxItem Text="RadComboBoxItem6" />
     </Items>
    </telerik:RadComboBox>
    JS:
    <script type="text/javascript">
     function OnClientSelectedIndexChanged(sender, args)
      {
       alert(sender.get_selectedItem().get_text());
      }
    </script>
    Please provide more information if it doesn't helps.

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. THANGARAI
    THANGARAI avatar
    21 posts
    Member since:
    Nov 2013

    Posted 19 May 2014 in reply to Princy Link to this post

    Hi Princy,
    in that above code, I added like 
    args.set_cancel(true);
    but its not stop postbacking.
    Please provide the solution to stop postback in OnClientIndexChanged event.

    thank you.
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 20 May 2014 in reply to THANGARAI Link to this post

    Hi THANGARAI,

    The OnClientSelectedIndexChanged client-side event occurs immediately after the selected item has changed. It is not possible to cancel this event. The OnClientSelectedIndexChanging client-side event occurs when the selected item is being changed. This event is fired before the combobox selection has changed to a new item. We can cancel this event to prevent the selection from changing. In order to achieve your scenario you can use OnClientSelectedIndexChanging event.

    Thanks,
    Princy.
  6. THANGARAI
    THANGARAI avatar
    21 posts
    Member since:
    Nov 2013

    Posted 20 May 2014 in reply to Princy Link to this post

    Thank you Princy.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017