Cancel postback when dropdown closed

3 posts, 1 answers
  1. Tauqir
    Tauqir avatar
    10 posts
    Member since:
    Jul 2013

    Posted 30 Sep 2013 Link to this post

    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. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 30 Sep 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Tauqir
    Tauqir avatar
    10 posts
    Member since:
    Jul 2013

    Posted 30 Sep 2013 Link to this post

    Thanks, it works perfectly. :)
Back to Top