[CLOSED] submitting file to ashx in IE browser

  1. #1

    [CLOSED] submitting file to ashx in IE browser

    IE popups a dialog to save a json file in the example bellow.Which is not true in other browsers
          <ext:FormPanel runat="server" ID="frmUploadImage" Layout="HBoxLayout" AnchorHorizontal="100%" BodyStyle="background-color:transparent" Border="false" Url="~/handlers/project_images.ashx/saveNewImages">
            <Items>
                  <ext:FileUploadField runat="server" ID="fufImageUpload" AllowBlank="false" ValidateBlank="true" Text="" Name="fileUpload"  Width="400" LabelWidth="125">
                   </ext:FileUploadField>
                 <ext:Button runat="server" ID="btnSaveImage" Text="Upload" Icon="DiskUpload" Flat="false">
                     <Listeners>
                       <Click Handler="Ext.getCmp('frmUploadImage').getForm().submit() ">
                       </Click>
                 </Listeners>
                </ext:Button>
     </ext:FormPanel>
    the handler returns
      msgBox.Show(new MessageBoxConfig()
                    {
                        Icon = MessageBox.Icon.ERROR,
                        Message = "Images size exceeds maximum allowed (1MB)!!!",
                        Title = "Project Images",
                        Fn = new JFunction { Handler = "mssoc.templates.fn.setFileUploadCaption();Ext.getStore('storeImageManagement').load();" }
                    }
     return new DirectResponse(msgBox.ToScript());
    In non IE browsers the messagebox box displays just fine but in IE it popups a dialog to download the json file.The content type is set correctly "application/json";
    Last edited by Daniil; Jul 14, 2014 at 10:19 AM. Reason: [CLOSED]
  2. #2
    Hi @odyssey,

    I think the IsUpload="true" setting might be required for a DirectResponse.
  3. #3

    IsUpload

    Well then the script is not being executed at all .It wrap ups the script in textarea tag
  4. #4
    It appears that it is a known IE issue when it tries to "download" an "application/json" response.
    http://stackoverflow.com/questions/1...nload-in-ie710

    Yes, IsUpload="true" wraps a response in a <textarea>. It is supposed to do that. And it helps to get it working in my test case.

    Page
    <%@ Page Language="C#" %>
    
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:FormPanel 
                ID="FormPanel1" 
                runat="server" 
                Url="TestHandler.ashx">
                <Items>
                    <ext:FileUploadField runat="server" Width="400" />
                    <ext:Button runat="server" Text="Upload" Handler="App.FormPanel1.getForm().submit();" />
                </Items>
            </ext:FormPanel>
        </form>
    </body>
    </html>
    ASHX
    using System.Web;
    using Ext.Net;
    
    namespace Work2
    {
        public class TestHandler : IHttpHandler
        {
            public void ProcessRequest(HttpContext context)
            {
                new DirectResponse
                {
                    Script = X.Msg.Alert("Title", "Message").ToScript(),
                    IsUpload = true
                }.Return();
            }
    
            public bool IsReusable
            {
                get
                {
                    return false;
                }
            }
        }
    }
  5. #5

    File upload

    You are right. Two things.
    First the requested method return type should be changed from DirectResponse to void ,and new DirectResponse shout include Return()
    like this
       new DirectResponse
            {
                Script = msgBox.ToScript(),
                IsUpload = true
            }.Return();

Similar Threads

  1. [CLOSED] Using CheckMenuItems for submitting Values?
    By blueworld in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Sep 24, 2013, 4:07 PM
  2. Submitting data from store in Grid
    By chezinho in forum 1.x Help
    Replies: 1
    Last Post: Dec 08, 2010, 3:36 PM
  3. [CLOSED] Submitting A DateField Value From A FormPanel
    By ilanga in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Sep 30, 2010, 12:00 PM
  4. Submitting form
    By okutbay in forum 1.x Help
    Replies: 1
    Last Post: Apr 22, 2010, 11:05 AM
  5. [CLOSED] [1.0] FormPanel submitting and EmptyText
    By tdracz in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Dec 16, 2009, 9:09 AM

Tags for this Thread

Posting Permissions