Server side event on Clear

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

    Posted 14 Aug 2013 Link to this post

    I want to execute some code on the server when the dropdowntree is cleared using the Clear button. How do I go about doing that? Thanks in advance.
  2. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 15 Aug 2013 Link to this post

    Hello Tauqir,

    Currently we do not have such server-side event of the RadDropDownTree control that you can use. However you can use the OnClientClearButtonClicked and the OnClientClearButtonClicking client side events.

    Regards,
    Kate
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. John
    John avatar
    31 posts
    Member since:
    May 2011

    Posted 26 Nov 2013 Link to this post

    Do you have any samples of how to implement this and triggering an event on the server side?

    I have got something to work. I add a custom event argument like this:
    function SectionComboBox_OnClientClearButtonClicked(sender, args) {
        __doPostBack('<%= rdtSectionId.UniqueID %>', 'ClearButtonClicked')
    }

    And then check for this on PostBack to fire my event:
    if (Page.IsPostBack && Request.Form["__EVENTTARGET"] == rdtSectionId.UniqueID && Request.Form["__EVENTARGUMENT"] == "ClearButtonClicked")
    {
        //fire my event
    }

    But this all seems a little messy.

    Is there a better way?

    Surely the EntryRemoved event should fire if you press the clear button and entries are removed as a result?

    This control seems a little half-baked to me!
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 27 Nov 2013 Link to this post

    Hi John,

    Please have a look into the following code snippet to call the server side RadButton OnClick event from RadDropDownTree OnClientClearButtonClicked event.

    ASPX:
    <telerik:RadDropDownTree ID="RadDropDownTree1" runat="server" DataSourceID="SqlDataSource1"
        DataFieldID="id" DataFieldParentID="parentid" DataTextField="text" OnClientClearButtonClicked="OnClientClearButtonClicked1">
        <ButtonSettings ShowClear="true" />
    </telerik:RadDropDownTree>
    <telerik:RadButton ID="RadButton1" runat="server" Text="Click" OnClick="RadButton1_Click">
    </telerik:RadButton>

    JavaScript:
    <script type="text/javascript">
        function OnClientClearButtonClicked1(sender, args) {
            var Button = $find("<%=RadButton1.ClientID %>");
            Button.click();
        }
    </script>

    C#:
    protected void RadButton1_Click(object sender, EventArgs e)
    {
        Response.Write("<script>alert('Fired');</script>");
           
    }

    Thanks,
    Shinu.
Back to Top