RadAjaxManager1_AjaxRequest doesn't fire for asp:linkbutton

2 posts, 0 answers
  1. nav100
    nav100 avatar
    48 posts
    Member since:
    Dec 2010

    Posted 19 Nov 2013 Link to this post

    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;        
        }
  2. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1803 posts

    Posted 22 Nov 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top