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

Server side event on Clear

3 Answers 101 Views
DropDownTree
This is a migrated thread and some comments may be shown as answers.
Tauqir
Top achievements
Rank 1
Tauqir asked on 14 Aug 2013, 02:01 PM
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.

3 Answers, 1 is accepted

Sort by
0
Kate
Telerik team
answered on 15 Aug 2013, 11:50 AM
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.
0
John
Top achievements
Rank 1
answered on 27 Nov 2013, 01:29 AM
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!
0
Shinu
Top achievements
Rank 2
answered on 27 Nov 2013, 06:42 AM
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.
Tags
DropDownTree
Asked by
Tauqir
Top achievements
Rank 1
Answers by
Kate
Telerik team
John
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or