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

RadAjaxManager1_AjaxRequest doesn't fire for asp:linkbutton

1 Answer 98 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
nav100
Top achievements
Rank 1
nav100 asked on 19 Nov 2013, 09:31 PM
I am trying to ajaxify the link button click event. But it doesn't fire. Here is my code.Could you please let me know what could be wrong?

    <asp:LinkButton ID="lnkTest" runat="server" />
    
       <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" EnableAJAX="true" DefaultLoadingPanelID="RadAjaxLoadingPanel1"
            OnAjaxRequest="RadAjaxManager1_AjaxRequest">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="LinkButton ">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="pnlGraph"></telerik:AjaxUpdatedControl>
                    </UpdatedControls>
        </AjaxSettings>
        </telerik:RadAjaxManager>

javascript
---------------------

            function raisePostBack(activity) {
                var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>");
                ajaxManager.ajaxRequest(activity);
            }

Code behind
---------

    lnkFinesValue.Text = String.Format("${0:C}", row["total_count"].ToString());.Text = String.Format("${0:C}", row["total_count"].ToString());
    lnkFinesValue.Text = String.Format("${0:C}", row["total_count"].ToString());.Attributes.Add("onClick", String.Format("raisePostBack('{0}');", "TEST"));


    protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
    {
      string test = e.Argument;        
    }

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 22 Nov 2013, 11:50 AM
Hi Nara,

In your AJAX settings you are have "LinkButton" as AjaxControlID, but in order to ajaxify the button you need to set its ID.

Furthermore, from the provided code snippet it is not clear what exactly you are trying to accomplish, especially the part with the "lnkFinesValue" in the code behind. The LinkButton ID in the markup is "lnkTest", so it is not clear what "lnkFinesValue" is.

Additionally, please have in mind that when ajaxRequest is fired from the RadAjaxManager, the manager itself must be set as initiator in the AJAX settings.

Here is a simple example of ajaxified LinkButton control:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="LinkButton1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="Label1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
 
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">LinkButton</asp:LinkButton>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
And the code behind:
protected void LinkButton1_Click(object sender, EventArgs e)
{
    Label1.Text = DateTime.Now.ToString();
}

Detail information for firing AJAX request through RadAjaxManager/RadAjaxPanel could be found at the following help article:

Hope that helps.


Regards,
Konstantin Dikov
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.
Tags
Ajax
Asked by
nav100
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or