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

How to exclude the AJAX post back for link button in GridView

3 Answers 172 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Jin
Top achievements
Rank 1
Jin asked on 04 Sep 2012, 07:30 AM
I have a search button and a RadGrid which will have a template to include a link button. The link button is used to download file. While click the search button, it will bind the GridView.I put a telerik:RadAjaxLoadingPanel to include the RadGrid and add following code:
 <telerik:RadAjaxManager ID="RadAjaxManager" runat="server">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="RadButtonSearch">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="RadGridHistory" LoadingPanelID="RadAjaxLoadingPanelHistory" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManager>

The problem is that the download link doesn't work while clicking. I think it's related with AJAX behavior and Response object. Whether there is a way to disable the AJAX post back for the link button in template column of RadGrid?

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 04 Sep 2012, 10:18 AM
Hi,

You can add a custom OnClick attribute to the linkbutton to register postback manually.
C#:
foreach (GridDataItem item in RadGrid1.Items)
{
    LinkButton link = (LinkButton)item.FindControl("LinkButton1");
    link.Attributes.Add("onclick", string.Format("realPostBack(\"{0}\", \"\"); return false;", link.UniqueID));
}
JS:
function realPostBack(eventTarget, eventArgument) {
       $find("<%= RadAjaxPanel1.ClientID %>").__doPostBack(eventTarget, eventArgument);
   }

Thanks,
Princy.
0
Rupesh
Top achievements
Rank 1
answered on 18 Oct 2014, 08:13 AM
I am getting  $find('RadAjaxPanel')=null in firebug watch window, so __doPostBack is not working and link button click performs AJAX post.

0
Viktor Tachev
Telerik team
answered on 22 Oct 2014, 10:38 AM
Hello Rupesh,

Note that when RadAjaxPanel is used any AJAX request initiated from a control wrapped in the panel updates the whole contents of the RadAjaxPanel.

If you would like to force an AJAX-enabled control to perform postback you should use one of the approaches described in the following article:
Regards,
Viktor Tachev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Ajax
Asked by
Jin
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Rupesh
Top achievements
Rank 1
Viktor Tachev
Telerik team
Share this question
or