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

Dropdownlist cancel postback

3 Answers 245 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Platinum
Top achievements
Rank 1
Platinum asked on 11 Oct 2016, 12:14 PM

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>

3 Answers, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 14 Oct 2016, 08:55 AM
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.
0
Platinum
Top achievements
Rank 1
answered on 14 Oct 2016, 10:24 AM
Hi, yes its set to true, but i would like not to do a post back when the selection is cleared via javascript.
0
Ivan Danchev
Telerik team
answered on 18 Oct 2016, 02:04 PM
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.
Tags
DropDownList
Asked by
Platinum
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Platinum
Top achievements
Rank 1
Share this question
or