[CLOSED] FileUploadField example does not work

  1. #1

    [CLOSED] FileUploadField example does not work

    Hi
    I can´t get this simple example to work from the Examples explorer. What is wrong?
    All I get is an client side error message "Error during uploading"

    Best regards
    Mikael J

    <%@ Page Language="C#" %>
    
    
    <script runat="server">
        protected void UploadClick(object sender, DirectEventArgs e)
        {
            string tpl = "Uploaded file: {0}<br/>Size: {1} bytes";
    
    
            if (this.FileUploadField1.HasFile)
            {
               X.Msg.Show(new MessageBoxConfig
                {
                    Buttons = MessageBox.Button.OK,
                    Icon = MessageBox.Icon.INFO,
                    Title = "Success",
                    Message = string.Format(tpl, this.FileUploadField1.PostedFile.FileName, this.FileUploadField1.PostedFile.ContentLength)
                });
            }
            else
            {
               X.Msg.Show(new MessageBoxConfig
                {
                    Buttons = MessageBox.Button.OK,
                    Icon = MessageBox.Icon.ERROR,
                    Title = "Fail",
                    Message = "No file uploaded"
                });
            }
        }
    </script>
    
    
    <!DOCTYPE html>
    
    
    <html>
    <head runat="server">
        <title>FormPanel - Ext.NET Examples</title>
        <link href="/resources/css/examples.css" rel="stylesheet" />
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
    
    
    
            <ext:FormPanel
                ID="BasicForm"
                runat="server"
                Width="500"
                Frame="true"
                Title="File Upload Form"
                PaddingSummary="10px 10px 0 10px"
                LabelWidth="50">
                <Defaults>
                    <ext:Parameter Name="anchor" Value="95%" Mode="Value" />
                    <ext:Parameter Name="allowBlank" Value="false" Mode="Raw" />
                    <ext:Parameter Name="msgTarget" Value="side" Mode="Value" />
                </Defaults>
                <Items>
                    <ext:TextField ID="PhotoName" runat="server" FieldLabel="Name" />
                    <ext:FileUploadField
                        ID="FileUploadField1"
                        runat="server"
                        EmptyText="Select an image"
                        FieldLabel="Photo"
                        ButtonText=""
                        Icon="ImageAdd"
                        />
                </Items>
                <Listeners>
                    <ValidityChange Handler="#{SaveButton}.setDisabled(!valid);" />
                </Listeners>
                <Buttons>
                    <ext:Button ID="SaveButton" runat="server" Text="Save" Disabled="true">
                        <DirectEvents>
                            <Click
                                OnEvent="UploadClick"
                                Failure="Ext.Msg.show({
                                    title   : 'Error',
                                    msg     : 'Error during uploading',
                                    minWidth: 200,
                                    modal   : true,
                                    icon    : Ext.Msg.ERROR,
                                    buttons : Ext.Msg.OK
                                });">
                            </Click>
                        </DirectEvents>
                    </ext:Button>
                    <ext:Button runat="server" Text="Reset">
                        <Listeners>
                            <Click Handler="#{BasicForm}.getForm().reset();" />
                        </Listeners>
                    </ext:Button>
                </Buttons>
            </ext:FormPanel>
        </form>
    </body>
    </html>
    Last edited by fabricio.murta; Oct 10, 2016 at 8:20 PM.
  2. #2
    Hello @Jurke!

    I don't understand, there might be some problem with your Ext.NET installation or project. I copypasted this on my testing project (and it is not the examples explorer project), and it worked just fine!

    Try a fresh install from sources, and maybe a fresh project. This is strange because also the other problem you pointed was not reproducible at our end.
    Fabrício Murta
    Developer & Support Expert
  3. #3
    This now works, I re installed Ext. Maybe something where wrong with the installation.

    /Mikael
  4. #4
    Glad it worked for you now!.. It turned out your other report was an actual bug, but an information for reproducing the issue was missing, in fact. Thanks for both the report and the feedback!

    If you ever dig down the other project and find specifically what was wrong with it to break the example, don't hesitate to share here! Maybe a missing setting in Web.config, or a conflicting reference. Can be anything.
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. [CLOSED] Dynamically loaded FileUploadField does not work
    By anwichmann in forum 3.x Legacy Premium Help
    Replies: 1
    Last Post: Sep 16, 2015, 4:12 PM
  2. [CLOSED] FileUploadField doesn't work as should
    By ViDom in forum 1.x Legacy Premium Help
    Replies: 23
    Last Post: Jul 16, 2012, 4:40 PM
  3. Replies: 7
    Last Post: Oct 14, 2011, 9:59 AM
  4. Replies: 7
    Last Post: Mar 28, 2011, 4:51 PM
  5. FileUploadField can't work
    By Fresh.Killer in forum 1.x Help
    Replies: 1
    Last Post: Dec 07, 2009, 8:26 AM

Posting Permissions