[CLOSED] file uploader

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [CLOSED] file uploader

    Hi,
    I am using your example for uploading a file, but when it comes to the "if (this.FileUploadField1.HasFile)" it is false when I am using a tool from the window to save. for testing purposes I tried using a direct event from the fileuploader and it works from there. But I need to upload the file during the save event, not before. please advise.

    <%@ Control Language="C#" %>
    
    <ext:DesktopModuleProxy ID="DesktopModuleProxy1" runat="server">
        <Module ModuleID="create-test">
            <Shortcut Name="test" IconCls="x-edits-shortcut" SortIndex="1" />
            <Launcher Text="test" Icon="Table"  />
            <Window>
    <ext:Window ID="Window1" runat="server" Width="500" Height="200">
        <Tools>
            <ext:Tool Type="Save" ToolTip="Save information" >
                <DirectEvents>
                    <Click OnEvent="UploadClick" /> <%--from here it does not work!!!--%>
                </DirectEvents>
            </ext:Tool>                      
       </Tools>
        <Items>
           <ext:FormPanel ID="FormPanel1" runat="server">
             <Items>
               <ext:FileUploadField runat="server" FieldLabel="Company Logo" EmptyText="Select an image" ButtonText="" ID="FileUploadField1" Icon="ImageAdd" >
                   <LeftButtons>
                      <ext:Button runat="server">
                          <DirectEvents>
                               <Click OnEvent="UploadClick" /> <%--from here it works--%>
                          </DirectEvents>
                      </ext:Button>
                   </LeftButtons>
                </ext:FileUploadField>
            </Items>
          </ext:FormPanel> 
        </Items>
    </ext:Window>
        </Window>
    </Module>
    </ext:DesktopModuleProxy>
    and in the code CodeBehind

     public void UploadClick(object sender, DirectEventArgs e)
            {
                string tpl = "Uploaded file: {0}<br/>Size: {1} bytes";
                if (this.FileUploadLogo.HasFile)
                {
                    //FileUploadLogo.PostedFile.SaveAs(
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Buttons = MessageBox.Button.OK,
                        Icon = MessageBox.Icon.INFO,
                        Title = "Success",
                        Message = string.Format(tpl, this.FileUploadLogo.PostedFile.FileName, this.FileUploadLogo.PostedFile.ContentLength)
                    });
                }
                else
                {
                    X.Msg.Show(new MessageBoxConfig
                    {
                        Buttons = MessageBox.Button.OK,
                        Icon = MessageBox.Icon.ERROR,
                        Title = "Fail",
                        Message = "No file uploaded"
                    });
                }
            }
    Last edited by Daniil; Sep 01, 2016 at 3:39 PM. Reason: [CLOSED]

Similar Threads

  1. [CLOSED] File select dialogue is not opening in Multiple File Upload
    By WHISHWORKS in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Nov 22, 2013, 11:28 AM
  2. [CLOSED] how do i assign image to <ext:image > from file uploader
    By amida in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Apr 08, 2013, 10:35 PM
  3. [CLOSED] File Uploader Not working for Large files(more than 2 MB)
    By alscg in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 07, 2013, 9:03 AM
  4. example about an uploader multi manager
    By tk.Mageztik in forum 2.x Help
    Replies: 1
    Last Post: Sep 13, 2012, 6:05 AM
  5. File uploader with the list of uploaded files
    By AlexMaslakov in forum 1.x Help
    Replies: 0
    Last Post: Aug 11, 2011, 11:56 AM

Tags for this Thread

Posting Permissions