Cancel Post back on OnClientSelectedIndexChanging....

5 posts, 0 answers
  1. Nate
    Nate avatar
    8 posts
    Member since:
    Aug 2007

    Posted 11 Feb 2008 Link to this post


    I have the following code:
    1  function OnClientSelectedIndexChanging(sender, eventArgs) 
    2      { 
    4        var vItem = eventArgs.get_item(); 
    6        if (vItem.get_value() == "..."
    7        { 
    8             alert('bad value'); 
    9             return false//cancel post back. 
    10        } 
    12      } 

    I get the alert box, but what do i need to do to cancel the post back?

  2. Helen
    Helen avatar
    1052 posts

    Posted 12 Feb 2008 Link to this post


    You should cancel the postback with the following code:


    Hope this helps.

    Kind regards,
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. DevCraft R3 2016 release webinar banner
  4. Maria
    Maria avatar
    4 posts
    Member since:
    Apr 2008

    Posted 23 Dec 2009 Link to this post

    How can I cancel  calling postback, but do not cancel selecting changed.

    if I use eventArgs.set_cancel(true) it do not save selected item
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 23 Dec 2009 Link to this post

    Hello Maria,

    You can simply set the AutoPostBack property of the RadComboBox to false which will still trigger the OnClientSelectedIndexChanged event. Also you can explicitly do postback using the __doPostBack() methods, whenever required.

  6. Aarsh
    Aarsh avatar
    192 posts
    Member since:
    Jun 2012

    Posted 11 Jan 2013 Link to this post

    I am using a combobox which has programatically populated suggestion list and allows custom-text. All worked as expected, except ... my combobox was asserting annoying post-backs on 'lost focus' or blur event even if the record was not in the suggestion box

    I did following on my rad combobox it seemed to be addressing my requirements somehow.

    function radComboBoxLostFocus(sender, args) {
                    if (document.getElementById("_ispostback") == 'True')

    And my markup looks something as below:

    <input type="hidden" id="_ispostback" value="<%=Page.IsPostBack.ToString() %>" />
    <telerik:RadComboBox ID="ddLastName" runat="server" AllowCustomText="true" CausesValidation="false"
        DropDownWidth="400px" Width="150px" EnableLoadOnDemand="true" EnableVirtualScrolling="true"  ClientIDMode="Static" ShowMoreResultsBox="true" AutoPostBack="True" OnItemsRequested="ddLastName_ItemsRequested" OnClientBlur="radComboBoxLostFocus()"
          OnSelectedIndexChanged="ddLastName_SelectedIndexChanged" ItemsPerRequest="10">
Back to Top
DevCraft R3 2016 release webinar banner