Export To Excel and Close Window without Prompt

4 posts, 0 answers
  1. Mike
    Mike avatar
    338 posts
    Member since:
    Jun 2008

    Posted 09 May 2013 Link to this post

    I have a webpage that has a RadGrid on it and when the page is opened I create an excel attachment using memory stream and send it in an email, then close the window. 

    This all works great, I even don't show a prompt to close the window. 

    I firmly beleive it has to do with this setting, OpenInNewWindow.  But when I do that
    RadGrid Grid1 = (RadGrid)Page.Master.FindControl("Main").FindControl("RadGrid1");
    Grid1.ExportSettings.OpenInNewWindow = true;

    However, at the bottom of the page there is a dialog to Open, Save or Cancel. 
    How can I disable this prompt? 

    I have attached images from IE 9 and FireFox 11.

    One trick I have seen and it works is to simply create a new html page and have a Redirect to that page at the end of the export that only has a window.close() in the JavaScript.
  2. Kostadin
    Kostadin avatar
    1733 posts

    Posted 14 May 2013 Link to this post

    Hi Michael,

    Another possible solution is to redirect to the same page. The following code snippet demonstrates the usage of FileStream and after it finished the page is reloaded again.
    protected void RadGrid1_GridExporting(object source, GridExportingArgs e)
        string path = Server.MapPath("~/MyFile.xls");
        using (FileStream fs = File.Create(path))
            Byte[] info = System.Text.Encoding.Unicode.GetBytes(e.ExportOutput);
            fs.Write(info, 0, info.Length);

    All the best,
    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.
  3. ArtiCut
    ArtiCut avatar
    5 posts
    Member since:
    Nov 2016

    Posted 06 Nov 2016 in reply to Kostadin Link to this post

    The command  " Response.Redirect(Request.Url.ToString());" redirect to the page,

    but the data at the radGrid is empty - the parameters at the page not saved. It's a problem...


    How can I come back to the page, but the parameters and the data should remain?

    or How  can I export to excel and prevent the following message to appear without redirect to the page?

  4. Daniel
    Daniel avatar
    4949 posts

    Posted 09 Nov 2016 Link to this post


    Please refer to my answer in the following thread:
    Export to pdf and save programmatically

    As to the other question, I'm not sure what parameters are lost in your code, but if you provide more details I may be able to help.

    Telerik by Progress
    Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
Back to Top