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

RadGrid OnItemCommand Event Still Running after Response.End();

1 Answer 99 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Giuliano Caetano
Top achievements
Rank 1
Giuliano Caetano asked on 29 Nov 2012, 10:46 AM
Hi Telerik team

I have a RadGrid with the a GridButtonColumn like below

<telerik:GridButtonColumn UniqueName="DeliveryNote" CommandName="DeliveryNote"
    ImageUrl="~/Content/Images/16/notes.png" ButtonType="ImageButton" Text="<%$ Resources:Resource, GridItemEditDeliveryNoteToolTip %>">
</telerik:GridButtonColumn>

CodeBehind:
protected void RadGridDeliveryNotesOnItemCommand(object sender, GridCommandEventArgs e)
{
    var gridDataItem = e.Item as GridDataItem;
    if (!ReferenceEquals(gridDataItem, null))
    {
        var idDeliveryNote = Convert.ToInt32(gridDataItem.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Id"]);
        if (e.CommandName == RadGrid.DeleteCommandName)
        {
             BL.Domain.DeliveryNote.Instance.DeleteById(idDeliveryNote);
        }
 
        if (e.CommandName == "DeliveryNote")
        {
            Response.Redirect(string.Format("Processor.ashx?idDeliveryNote={0}", idDeliveryNote), true);
        }
    }
}


.ashx

public class Processor : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        var idDeliveryNote = context.Request.ProcessQueryString("idDeliveryNote");
 
        var report = new Reports.DeliveryNote();
        report.ReportParameters["IdDeliveryNote"].Value = idDeliveryNote;
 
        context.Response.Clear();
        context.Response.Buffer = true;
        context.Response.ClearHeaders();
        context.Response.ClearContent();
 
        var reportProcessor = new ReportProcessor();
 
        var pdfResult = reportProcessor.RenderReport("PDF", report, null);
        var file = pdfResult.DocumentBytes;
 
        context.Response.ContentType = "application/pdf";
 
        context.Response.Charset = string.Empty;
        context.Response.AddHeader("Content-Length", file.Length.ToString(CultureInfo.CurrentCulture));
        var attachment = string.Format("attachment; filename={0}.{1}", "file-name", "pdf");
        context.Response.AddHeader("content-disposition", attachment);
 
        var bytes = file;
        context.Response.BinaryWrite(bytes);
        context.Response.End();
    }
}


The problem is, The loading pannel over RadGrid, still running after the file exported.
Can you help me with this issue.

Thanks
Giuliano


1 Answer, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 04 Dec 2012, 10:05 AM
Hi Giuliano,

Please note that using "Response.Write" with async postback is not a supported scenario and this is MS Ajax framework limitation. I suppose that the ajax request has break due to this method and therefore the LoadingPanel could not hide. Please try to disable the ajax on this specific button click and verify if this helps.

Regards,
Maria Ilieva
the Telerik team
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 their blog feed now.
Tags
Grid
Asked by
Giuliano Caetano
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Share this question
or