[CLOSED] Excel not generated by Direct Event

  1. #1

    [CLOSED] Excel not generated by Direct Event

    Hi Team,

    I am trying to generate a Excel download by a Direct Event button click defined as below -

    ============== aspx code ===================
    <ext:Button ID="extBtn1" runat="server" Text="ToExcel-2">
                                    <DirectEvents>
                                        <Click OnEvent="ToExcel">
                                            <EventMask ShowMask="true" />
                                        </Click>
                                    </DirectEvents>
                                </ext:Button>
    with the event method defined as below -

    ============== C# ======================
     protected void ToExcel(object sender, EventArgs e)
        {
    
            XElement eml = new XElement("Records",
                    new XElement("Record",
                        new XElement("SiteName"),
                        new XElement("TotalInstallCost"),
                        new XElement("TotalMonthlyCost","2000")
                    )
                );
    
    
            XmlDocument xmlDoc = new XmlDocument();
    
            using (System.Xml.XmlReader xmlReader = eml.CreateReader())
            {
    
                xmlDoc.Load(xmlReader);
    
            }
    
            XmlNode xmlNode = xmlDoc; //.DocumentElement;
    
            this.Response.Clear();
            this.Response.ContentType = "application/vnd.ms-excel";
            this.Response.AddHeader("Content-Disposition", "attachment; filename=submittedData.xls");
            XslCompiledTransform xtExcel = new XslCompiledTransform();
            xtExcel.Load(Server.MapPath("Excel.xslt"));
            xtExcel.Transform(xmlNode, null, this.Response.OutputStream);
            HttpContext.Current.ApplicationInstance.CompleteRequest();
            this.Response.Flush();
            this.Response.Close();
            //this.Response.End();
        }
    However the method does not generate the Excel report and seems to diffuse the output stream, with no error or output to the user screen.

    Please advice.

    Thanks
    Last edited by Daniil; Apr 16, 2013 at 5:32 AM. Reason: [CLOSED]
  2. #2
    Hi Tarun,

    You should, at least, set up IsUpload to true.
    <Click OnEvent="ToExcel" IsUpload="true">
    Also EventMask doesn't work with AJAX downloading, because it doesn't fire any event after downloading. So, no way to determine when hide a mask.

    The following can help with some scenarios.
    http://forums.ext.net/showthread.php?19430#post83757

Similar Threads

  1. [CLOSED] Output Cache issue with Direct Method / Direct Event
    By amitpareek in forum 1.x Legacy Premium Help
    Replies: 18
    Last Post: Mar 01, 2013, 5:03 AM
  2. Replies: 2
    Last Post: Feb 08, 2013, 8:40 PM
  3. Replies: 4
    Last Post: Jul 12, 2012, 2:29 PM
  4. Replies: 4
    Last Post: Sep 14, 2011, 8:01 PM
  5. Replies: 3
    Last Post: Apr 20, 2010, 12:21 PM

Tags for this Thread

Posting Permissions