New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

How to Trigger Server-Side Click Event in RadFloatingActionButton for ASP.NET AJAX

Environment

Property Value
Product RadFloatingActionButton for ASP.NET AJAX
Version all

Description

I want to trigger a server-side click event in RadFloatingActionButton for ASP.NET AJAX, but it is not getting triggered by default.

Solution

By default, the RadFloatingActionButton does not trigger server-side events. However, you can still achieve this by making a PostBack using the __doPostBack() function.

Here's how:

  1. Add the following JavaScript code to your page:
<script>
function OnClientClicked(ev) {
    var floatingActionButtonId = ev.get_id();
    __doPostBack(floatingActionButtonId, "SomeArguments");
}
</script>
  1. Modify your RadFloatingActionButton control to include the OnClientClicked client event:
<telerik:RadFloatingActionButton runat="server" ID="RadFloatingActionButton1" Icon="save" PositionMode="Fixed" Text="Save">
    <ClientEvents OnClick="OnClientClicked" />
</telerik:RadFloatingActionButton>
  1. In the code-behind (C#), capture the event in the Page_Load method:
protected void Page_Load(object sender, EventArgs e)
{
    string eventTarget = Request["__EVENTTARGET"]; // RadFloatingActionButton1

    if (!string.IsNullOrWhiteSpace(eventTarget) && eventTarget == RadFloatingActionButton1.ClientID)
    {
        string parameter = Request["__EVENTARGUMENT"]; // SomeArguments

        // Handle the event here
    }
}
Protected Sub Page_Load(sender As Object, e As EventArgs)
    Dim eventTarget As String = Request("__EVENTTARGET") ' RadFloatingActionButton1

    If Not String.IsNullOrWhiteSpace(eventTarget) AndAlso eventTarget = RadFloatingActionButton1.ClientID Then
        Dim parameter As String = Request("__EVENTARGUMENT") ' SomeArguments
        ' Handle the event here
    End If
End Sub

That's it! You can now trigger a server-side click event in RadFloatingActionButton for ASP.NET AJAX using the provided solution.

Notes

Make sure to replace RadFloatingActionButton1 with the actual ID of your RadFloatingActionButton control in the Page_Load method.

In this article