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

Cancel postback when dropdown closed

2 Answers 30 Views
DropDownTree
This is a migrated thread and some comments may be shown as answers.
Tauqir
Top achievements
Rank 1
Tauqir asked on 30 Sep 2013, 09:39 AM
I am trying to cancel postback when the dropdown is closed, something similar to what is happening here, http://www.telerik.com/help/aspnet-ajax/treeview-onclientnodeclicking.html.

function ClientNodeClicking(sender, eventArgs) {
        var node = eventArgs.get_node();
        if (node.get_text() == "Search") {
            eventArgs.set_cancel(true);
        }
    }
How can I go about doing the same thing for the RadDropDownTree? The functionality on the client side event OnClientDropDownClosed should do the trick. Thanks, Tauqir.

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 1
answered on 30 Sep 2013, 10:52 AM
Hi Tauqir,

Please have a look  into the following code snippet that I tried to cancel postback on OnClientDropDownClosing event.

ASPX:
<telerik:RadDropDownTree ID="RadDropDownTree1" OnClientDropDownClosing="OnClientDropDownClosing"
    AutoPostBack="true" runat="server" DataSourceID="SqlDataSource1" DataFieldID="id"
    DataFieldParentID="parentid" DataTextField="text" DataValueField="id">
</telerik:RadDropDownTree>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Northwind_newConnectionString %>"
    SelectCommand="SELECT * FROM [Details]"></asp:SqlDataSource>

JavaScript:
<script type="text/javascript">
    function OnClientDropDownClosing(sender, args) {
        if (sender.get_selectedText() == "Item 1") {
            sender._autoPostback = false;
        }
        else {
            sender._autoPostback = true;
        }
    }
</script>

Thanks,
Shinu.
0
Tauqir
Top achievements
Rank 1
answered on 30 Sep 2013, 02:30 PM
Thanks, it works perfectly. :)
Tags
DropDownTree
Asked by
Tauqir
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Tauqir
Top achievements
Rank 1
Share this question
or