[CLOSED] Save Dialog v0.8.1

  1. #1

    [CLOSED] Save Dialog v0.8.1

    Hi, I am using the following code to open a save dialog from codebehind, but I am getting this error:

    Request Failure
    Bad Response: Invalid Character

    
    private bool responseEnd = false;
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            Button1.AjaxEvents.Click.Event += new Coolite.Ext.Web.ComponentAjaxEvent.AjaxEventHandler(Click_Event);
            this.LoadComplete += new EventHandler(LoadCompleteHandler);
        }
    
        private void LoadCompleteHandler(object sender, EventArgs e)
        {
            if (responseEnd)
            {
                Response.End();
            }
        }
        void Click_Event(object sender, Coolite.Ext.Web.AjaxEventArgs e)
        {
            //This doesn't work
            //Response.ContentType = "image/jpeg";
            //Response.AppendHeader("Content-Disposition", "attachment; filename=image1.jpeg");
            //Response.TransmitFile(Server.MapPath("~/Images/image1.jpeg"));
            //Response.End();
    
            this.Context.Response.Clear();
            this.Context.Response.AddHeader("Content-Disposition", string.Format("attachment; filename=person.jpg"));
            this.Context.Response.ContentType = "application/octet-stream";
            this.Context.Response.WriteFile(string.Format("C:/person.jpg"));
        }
    Any Ideas?
    Last edited by Daniil; Aug 09, 2010 at 4:36 PM.
  2. #2
    Hi,

    Please set IsUpload="true" for the AjaxEvent
  3. #3

    Re:

    Thanks, it worked nicely. Can you explain me why?

    Mark it as solved.

    Btw, I added:

    Button1.AjaxEvents.Click.IsUpload = true;
  4. #4
    Hi,

    Here is the quote 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. Replies: 1
    Last Post: Nov 02, 2012, 4:07 AM
  2. Save as dialog on client side for image
    By vishal.jhala@gmail.com in forum 1.x Help
    Replies: 0
    Last Post: Aug 06, 2011, 8:02 PM
  3. Fileupload after Save Dialog issue
    By reyonlines in forum 1.x Help
    Replies: 5
    Last Post: Jan 03, 2011, 5:27 PM
  4. Get the value from prompt dialog and save
    By CoolNoob in forum 1.x Help
    Replies: 5
    Last Post: Oct 23, 2009, 2:13 PM
  5. [CLOSED] Save as dialog?
    By Jurke in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 01, 2009, 12:53 PM

Posting Permissions