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

Save grid to PDF and don't display dialog box

1 Answer 61 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mark Hinchliffe
Top achievements
Rank 1
Mark Hinchliffe asked on 24 Sep 2010, 10:46 AM
Hi,

I've got the following code that I am running server-side to export the grid and save it to PDF. I then don't want to show the Dialog box to the user so I can then do more in code to attach the saved PDF to an email.

This is the code I have to save the file:

protected void grdDailyList_GridExporting(object source, Telerik.Web.UI.GridExportingArgs e)
        {
            string path = Server.MapPath("~/DailyList/list.pdf");
            if (File.Exists(path))
                File.Delete(path);
  
            using (FileStream fs = File.Create(path))
            {
                Byte[] info = System.Text.Encoding.Default.GetBytes(e.ExportOutput);
                fs.Write(info, 0, info.Length);
            }
  
  
        }

How do I then prevent the dialog box from getting displayed?

Or can I move the above code to get the grids ExportOutput code without having to go through this method?

Thanks, Mark

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 24 Sep 2010, 11:31 AM
Hello Mark,

The only way to avoid the dialog at this point is to refresh the page as demonstrated in this blog post:
Export grid to PDF file and show the result using the window

As to the second question - this is the earliest point where you can get the output.

Kind regards,
Daniel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Mark Hinchliffe
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or