[CLOSED] Export Data with Type= Load

  1. #1

    [CLOSED] Export Data with Type= Load

    Hey,
    I have a button with Click event and type=load. I am trying to export some content. However, with Type=load present, I get error "Unterminated String literal" in Chrome or "Invalid Syntax : Missing Parathesis )" in FF. I remove Type=Load and everything works as expected.

    The following is the markup and code :


    <ext:Button runat="server" Text="Export">
                    <DirectEvents>
                        <Click OnEvent="export" Type="Load" IsUpload="true"></Click>
                    </DirectEvents>
    </ext:Button>
     protected void export(object sender, DirectEventArgs e) {
    this.Response.Clear();
                this.Response.ContentType = "application/octet-stream";
                this.Response.AddHeader("Content-Disposition", "attachment; filename=exportedData.csv");
                byte[] b = Response.ContentEncoding.GetBytes("'Amit'");
                this.Response.BinaryWrite(b);
                this.Response.End();
                //
            }
    Last edited by Daniil; Aug 12, 2010 at 10:33 AM. Reason: [CLOSED]
  2. #2
    Hello, amitpareek!

    I can't reproduce the issue using the code you provided. Please provide us with a full sample code which would cause the issue.

    When did you update from SVN repository at the last time? if it was long ago please update and retest your application.
  3. #3
    Hi,
    The error comes when I have large amount of data with a few syntax otherwise no error but neither any file is generated.

    However, I am pretty much sure that even with latest version from SVN, I was unable to export the file with Type=Load. Check the attached, I get the response from server, but no file gets exported. Just when I remove type=load, the exportedData.xls is sent to client.
    Attached Thumbnails Click image for larger version. 

Name:	ff.png 
Views:	92 
Size:	63.1 KB 
ID:	1460  
  4. #4
    Hi,

    Unfortunately, you cannot use Type="Load" with IsUpload="true" because IsUpload requires a form but Type="Load" excludes the form.
    I suppose that you use Type="Load" to exclude form submitting.

    I can suggest to use an empty form and set its id to the FormID of the DirectEvent
    Please see the following sample

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void export(object sender, DirectEventArgs e)
        {
            this.Response.Clear();
            this.Response.ContentType = "application/octet-stream";
            this.Response.AddHeader("Content-Disposition", "attachment; filename=exportedData.csv");
            byte[] b = Response.ContentEncoding.GetBytes("'Amit'");
            this.Response.BinaryWrite(b);
            this.Response.End();
            //
        }
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.NET Example</title>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
       
        <ext:Button runat="server" Text="Export">
            <DirectEvents>
                <Click OnEvent="export" IsUpload="true" Method="POST" FormID="proxyForm">
                </Click>
            </DirectEvents>
        </ext:Button>
        
        </form>
        
        <form id="proxyForm" class="x-hidden" />
    </body>
    </html>

    P.S.
    The error comes when I have large amount of data with a few syntax otherwise no error but neither any file is generated.
    Type="Load" uses GET request by default. GET request has limitation on passed data (aprx 4kb). Therefore please set Method="POST" for DirectEvent when you use Type="Load" and have large amount of data
  5. #5
    Thanks vlad,
    I wil try this tonite. One more small query.

    On that button if i add event mask properties, the mask is shown on click, but remains as is even after the file is exported. So i have to refrwsh the page. What should i do in this case?
  6. #6
    Hi,

    Unfortunately, if you return the file then iframe (which uses as file transport) doesn't raise any events. Therefore we cannot hide the mask. The single solution do not use the mask if you return a file

    Here is the note from ExtJS docs
    isUpload : Boolean (Optional)
    Only meaningful when used with the form option.
    True if the form object is a file upload (will be set automatically if the form was configured with enctype "multipart/form-data").
    File uploads are not performed using normal "Ajax" techniques, that is they are not performed using XMLHttpRequests. Instead the form is submitted in the standard manner with the DOM <form> element temporarily modified to have its target set to refer to a dynamically generated, hidden <iframe> which is inserted into the document but removed after the return data has been gathered.
    The server response is parsed by the browser to create the document for the IFRAME. If the server is using JSON to send the return object, then the Content-Type header must be set to "text/html" in order to tell the browser to insert the text unchanged into the document body.
    The response text is retrieved from the document, and a fake XMLHttpRequest object is created containing a responseText property in order to conform to the requirements of event handlers and callbacks.
    Be aware that file upload packets are sent with the content type multipart/form and some server technologies (notably JEE) may require some custom processing in order to retrieve parameter names and parameter values from the packet content.

Similar Threads

  1. Change input type based on data type
    By bjones in forum 1.x Help
    Replies: 5
    Last Post: Jan 06, 2012, 9:54 AM
  2. [CLOSED] Stop treepanel to load data on page load
    By inayath in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Feb 11, 2011, 10:17 AM
  3. Replies: 1
    Last Post: Apr 19, 2010, 2:44 PM
  4. Replies: 2
    Last Post: Jan 26, 2009, 12:12 PM
  5. Replies: 0
    Last Post: Nov 04, 2008, 11:25 AM

Posting Permissions