[CLOSED] Difficulty for IE when PartialView tries to Upload File

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Difficulty for IE when PartialView tries to Upload File

    Hi guys,

    This problem shows only by IE.

    1. This view works fine.
    
    <%@ Control Language="C#" %>
    <ext:Window runat="server" ID="win" Layout="FitLayout" CloseAction="Destroy" 
        Width="300" Height="200" Border="false">
        <Items>
            <ext:FormPanel runat="server" BodyPadding="20">
                <Items>
                    <ext:FileUploadField runat="server" ID="uField" IDMode="Static" AnchorHorizontal="100%">
                        <DirectEvents>
                            <Change Url="/test.aspx/upload" />
                        </DirectEvents>
                    </ext:FileUploadField>
                </Items>
            </ext:FormPanel>
        </Items>
        <Buttons>
            <ext:Button runat="server" Text="Close">
                <Listeners>
                    <Click Handler="#{win}.close();" />
                </Listeners>
            </ext:Button>
        </Buttons>
    </ext:Window>

    2. This view doesn't work (extra js code block added)

    
    <%@ Control Language="C#" %>
    <ext:Window runat="server" ID="win" Layout="FitLayout" CloseAction="Destroy" 
        Width="300" Height="200" Border="false">
        <Items>
            <ext:FormPanel runat="server" BodyPadding="20">
                <Items>
                    <ext:FileUploadField runat="server" ID="uField" IDMode="Static" AnchorHorizontal="100%">
                        <DirectEvents>
                            <Change Url="/test.aspx/upload" />
                        </DirectEvents>
                    </ext:FileUploadField>
                </Items>
            </ext:FormPanel>
        </Items>
        <Buttons>
            <ext:Button runat="server" Text="Close">
                <Listeners>
                    <Click Handler="#{win}.close();" />
                </Listeners>
            </ext:Button>
        </Buttons>
    </ext:Window>
    <script type="text/javascript">
        Ext.ns("MyNamespace");
    </script>
    IE prompts an error telling "Access denied" (attached).
    Any ideas?
    Attached Thumbnails Click image for larger version. 

Name:	error.jpg 
Views:	30 
Size:	36.6 KB 
ID:	6092  
    Last edited by Daniil; Apr 29, 2013 at 5:08 AM. Reason: [CLOSED]
  2. #2
    Hi @cleve,

    Please try to move the script block into the Window's HtmlBin. Does it help?
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi @cleve,

    Please try to move the script block into the Window's HtmlBin. Does it help?
    Sorry, it doesn't work. The following is the complete example. My IE version is 9.0.8112.*.

    Controller "Test"
    
            public ActionResult Index()
            {
                return View(@"~/test/index.aspx");
            }
    
            public ActionResult Test(string id)
            {
                Ext.Net.MVC.PartialViewResult r = this.PartialExtView("~/test/control1.ascx");
                r.ContainerId = "c";
                r.RenderMode = RenderMode.AddTo;
                r.ClearContainer = true;
                r.ControlId = "x";
                r.IDMode = IDMode.Client;
                return r;
            }
    Index.aspx

    
    <%@ Page Language="C#" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <body id="theBody">
        <ext:ResourceManager ID="theManager" runat="server"
            ShowWarningOnAjaxFailure="false"
            DirectMethodProxy="Ignore"
            ScriptMode="Debug">
            <Listeners>
            </Listeners>
        </ext:ResourceManager>
        <ext:Viewport runat="server">
            <Items>
                <ext:Button runat="server" Text="Inject to Upload">
                    <DirectEvents>
                        <Click Url="/test.aspx/test" />
                    </DirectEvents>
                </ext:Button>
            </Items>
        </ext:Viewport>
        <ext:Container runat="server" ID="c" />
    </body>
    </html>
    Control1.ascx
    <%@ Control Language="C#" %>
    <ext:Window runat="server" ID="win" Layout="FitLayout" CloseAction="Destroy" 
        Width="300" Height="200" Border="false">
        <Items>
            <ext:FormPanel runat="server" BodyPadding="20">
                <Items>
                    <ext:FileUploadField runat="server" ID="uField" IDMode="Static" AnchorHorizontal="100%">
                        <DirectEvents>
                            <Change Url="/test.aspx/upload" />
                        </DirectEvents>
                    </ext:FileUploadField>
                </Items>
            </ext:FormPanel>
        </Items>
        <Buttons>
            <ext:Button runat="server" Text="Close">
                <Listeners>
                    <Click Handler="#{win}.close();" />
                </Listeners>
            </ext:Button>
        </Buttons>
        <HtmlBin>
            <script type="text/javascript">
                Ext.ns("MyNamespace");
            </script>
        </HtmlBin>
    </ext:Window>
    I believe it's the problem of IE in a particular version (IE9). Can you guys confirm in your side that problem exists? If it can be reproduced, I'll try something else. Many thanks.
  4. #4
    I am able to reproduce the problem with this simple example. Can you confirm?

    Example
    <%@ Page Language="C#" %>
    
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>Ext.NET Example</title>
    </head>
    <body>
        <ext:ResourceManager runat="server" />
    
        <ext:FormPanel 
            ID="FormPanel1" 
            runat="server" 
            Url="/ASPX/Upload" 
            Width="300">
            <Items>
                <ext:FileUploadField runat="server" AnchorHorizontal="100%" />
            </Items>
        </ext:FormPanel>
    
        <ext:Button runat="server" Text="Submit" Handler="#{FormPanel1}.submit();" />
    </body>
    </html>
    Interesting, but this same page doesn't reproduce the problem with WebForms.
  5. #5
    Quote Originally Posted by Daniil View Post
    I am able to reproduce the problem with this simple example. Can you confirm?

    Example
    <%@ Page Language="C#" %>
    
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>Ext.NET Example</title>
    </head>
    <body>
        <ext:ResourceManager runat="server" />
    
        <ext:FormPanel 
            ID="FormPanel1" 
            runat="server" 
            Url="/ASPX/Upload" 
            Width="300">
            <Items>
                <ext:FileUploadField runat="server" AnchorHorizontal="100%" />
            </Items>
        </ext:FormPanel>
    
        <ext:Button runat="server" Text="Submit" Handler="#{FormPanel1}.submit();" />
    </body>
    </html>
    Interesting, but this same page doesn't reproduce the problem with WebForms.
    Em.. Yea. It show JSON encode error of some kind. But it looks different with the previous of mine. Mine is "Access Denied.".
    But when I trace back the source, it focuses the same thing "form.submit()".
    When I google search the keyword, It's been generally discussed on iFrame document domain issue. When I further narrow down the problem scope, I come up with some hints not sure if it's helpful.
    1. For partial view injection, when "<script type='...." tag is cleared, that is, no JS <script> trunk in partial view control, upload works fine. form.submit won't prompt any error;
    2. If JS <script> trunk's added. "Access Denied" error shows. When inspecting the generated code snippet, only several bytes e.g. "<script type='text/javascript'>window.alert('hi');</script>" have been added to the body by Ext.net.append(). Does it mean appending "<script>" breaks the domain consistency?
    3. The strangest thing is, when I capture the problematic code snippet and run under "captureRun();", it works fine!

    
    var captureRun = function(){
    
    Ext.ComponentManager.onAvailable("c",function(){Ext.net.append(Ext.getBody(),["<div id=\"x_Content\" class=\"x-hidden\">","<script type=\"text/javascript\">","    // Ext.ns(\"MyNamespace\");","<\/script></div>"].join(''));Ext.net.ResourceMgr.destroyCmp("App.x");Ext.getCmp("c").removeAll();Ext.create("Ext.window.Window",{id:"x_UC_win",border:false,height:200,hidden:false,renderTo:Ext.getBody(),width:300,items:[{xtype:"form",items:[{id:"x_UC_uField",xtype:"filefield",anchor:"100%",directEvents:{change:{fn:function(item,newValue,oldValue){Ext.net.directRequest({cleanRequest:true,url:"/test.aspx/upload",control:this,action:'Change'});}}}}],bodyPadding:20}],layout:"fit",buttons:[{text:"Close",listeners:{click:{fn:function(item,e){App.x_UC_win.close();}}}}],closeAction:"destroy"});Ext.getCmp("c").add({id:"x",border:false,xtype:"container",contentEl:"x_Content"});});
    
    }
    Does that mean "window.execScript()" should be checked whether it brings the problem?
  6. #6
    That example reproduced "Access Denied" error for me.

    Ok, here is a simplified example.

    View
    <%@ Page Language="C#" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Ext.NET Example</title>
    </head>
    <body>
        <ext:ResourceManager runat="server" />
    
        <ext:Button runat="server" Text="Inject to Upload" DirectClickAction="Test" />
    </body>
    </html>
    Partial View
    <%@ Control Language="C#" %>
    
    <ext:Window
        runat="server" 
        Width="300" 
        Height="200"
        Layout="FitLayout">
        <Items>
            <ext:FormPanel runat="server">
                <Items>
                    <ext:FileUploadField runat="server" AnchorHorizontal="100%">
                        <DirectEvents>
                            <Change Action="Upload" />
                        </DirectEvents>
                    </ext:FileUploadField>
                </Items>
            </ext:FormPanel>
        </Items>
        <HtmlBin>
            <script type="text/javascript">
                Ext.ns("MyNamespace");
            </script>
        </HtmlBin>
    </ext:Window>
    Controller Actions
    public ActionResult Index()
    {
        return View();
    }
    
    public ActionResult Test()
    {
        return this.PartialExtView("Test");
    }
    
    public ActionResult Upload()
    {
        return new FormPanelResult() { IsUpload = true };
    }
    It reproduces the "Access denied" error for me regardless there is a <script> in the partial view or not.
  7. #7
  8. #8
    I have tried the suggestions from the mentioned links. Unfortunately, nothing seems to be working for me.

    I think it is IE9 bug. It appears to be working with IE10.

    The best I can suggest to get it working is placing a Window directly on the page.
  9. #9
    Quote Originally Posted by Daniil View Post
    I have tried the suggestions from the mentioned links. Unfortunately, nothing seems to be working for me.

    I think it is IE9 bug. It appears to be working with IE10.

    The best I can suggest to get it working is placing a Window directly on the page.
    Can you post some technical details that can fully address this problem?
    Limit the scenario to "how to make upload on-the-fly", do you have some suggestions at this moment?
  10. #10
    Quote Originally Posted by cleve View Post
    Can you post some technical details that can fully address this problem?
    Not sure what details you are expecting. Could you clarify? I have no idea why IE denies access on this scenario. IMO, it should not.

    The problem seems to be not related to Ext.NET or ExtJS since the same is reproducible without it as it is discussed in the links.

    Quote Originally Posted by cleve View Post
    Limit the scenario to "how to make upload on-the-fly", do you have some suggestions at this moment?
    Is this not suitable for you?
    The best I can suggest to get it working is placing a Window directly on the page.
    You could leave it in a user control, but put it on the page at once.

    If you are unwilling to put a Window on the page at once, you could try to create it via JavaScript.
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] multiple file upload and file size at client side
    By mirwais in forum 1.x Legacy Premium Help
    Replies: 24
    Last Post: Dec 15, 2014, 5:44 AM
  2. Replies: 1
    Last Post: Mar 15, 2013, 1:38 AM
  3. [CLOSED] Multiple file support to upload in file upload control
    By legaldiscovery in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Feb 01, 2013, 9:41 AM
  4. Replies: 9
    Last Post: Nov 14, 2012, 2:59 PM
  5. Replies: 1
    Last Post: Jun 23, 2011, 9:37 AM

Posting Permissions