Dropdownlist cancel postback

4 posts, 0 answers
  1. Platinum
    Platinum avatar
    31 posts
    Member since:
    Jan 2008

    Posted 11 Oct Link to this post

    Hi,

    I am using RadTabstrip and Raddropdownlist.

     

    Whenever the RadTabstrip is selected, the values selected in dropdownlist should be cleared, but i notice whenever i use the  categoryList.get_selectedItem().unselect(); it causes to postback. How to cancel the post back ?

     

    I am using this code below

     

     <script type="text/javascript">
    function OnClientTabSelected(sender, eventArgs)
    {
        var tab = eventArgs.get_tab();    
        var categoryList = $find("<%=rdddlCategory.ClientID %>");   
        if (categoryList.get_selectedItem()) {      
            //categoryList.get_selectedItem().set_selected(false);
            categoryList.get_selectedItem().unselect();
           
        }
    }

            function OnClientCategorySelected(sender, eventArgs) {
                alert();
                var tabstrip = $find('<%= rdTpEvents.ClientID %>');            
                if (tabstrip.get_selectedTab().get_text() != "Latest" && tabstrip.get_selectedTab().get_text() != "Working") {              
                    eventArgs.set_cancel(true);
                }
            }

    </script>

  2. Ivan Danchev
    Admin
    Ivan Danchev avatar
    832 posts

    Posted 14 Oct Link to this post

    Hello,

    You haven't posted your DropDownList markup declaration but I assume its AutoPostBack property is set to "true", which will lead to a postback being initiated when a change in the selection occurs (more information is available in this documentation article). Could you try setting it to "false" and check whether this changes the behavior?

    Regards,
    Ivan Danchev
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Platinum
    Platinum avatar
    31 posts
    Member since:
    Jan 2008

    Posted 14 Oct in reply to Ivan Danchev Link to this post

    Hi, yes its set to true, but i would like not to do a post back when the selection is cleared via javascript.
  5. Ivan Danchev
    Admin
    Ivan Danchev avatar
    832 posts

    Posted 18 Oct Link to this post

    Hello,

    This is not supported by the DropDownList. By design when its AutoPostBack property is set to "true" selecting/unselecting an item will initiate a postback regardless of the action being triggered by a mouse click or by javascript.

    Regards,
    Ivan Danchev
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top