[CLOSED] File upload Hasfile false

  1. #1

    [CLOSED] File upload Hasfile false

    Code in View

    @using Ext.Net.MVC
    @using Ext.Net
    
    @{
        ViewBag.Title = "Confirm MessageBox with ButtonsConfig - Ext.NET MVC Examples";
        Layout = null;
        var X = Html.X();
    }
    @X.ResourceManager()
    
    <form id="fileUpload" enctype="multipart/form-data">
    @(
     X.FormPanel().X(0).Y(190)
            .ID("f")
            .BodyPadding(5)
            .Border(false)
            
    .Items
    (
    X.Window().Width(500).Items(
     X.TabPanel().Border(false).BodyStyle("background-color: #F1F1F1;")
                                    .Items(
                
            // TAB PERSONAL INFORMATION
                                        X.FormPanel().Width(550).Padding(5)
                                        .Title("Personal Information").BodyStyle("background-color: #F1F1F1;").Border(false).Icon(Icon.UserGrayCool)
                                            .Items
                                                (
                                                 X.FileUploadField()
                                                            .Icon(Icon.Attach)
                                                            .ID("fuCompany_Logo_path")
                                                            .FieldLabel("Company Logo")
                                                            .AnchorHorizontal("100%")
                                                            .EmptyText("Company Logo")
                                                              .AllowBlank(false)
                                                              
                                                              
                                                              
                                                            )
                                                            )
                                                            )
                                                            .Buttons
                                                            (
                                                                    
                                                                X.Button()
                                                                 .Text("Save")
                                                            .ID("btnSave")
                                                            .DirectEvents(de =>
                                                            {
                                                                de.Click.Before = "return validation()";
                                                                de.Click.FormID = "fileUpload";
                                                                de.Click.Action = "save";
                                                                de.Click.EventMask.ShowMask = true;
                                                                de.Click.EventMask.Msg = "Saving...";
                                                                de.Click.EventMask.MinDelay = 100;
                                                               // de.Click.After = "App.GridPanel1.getStore().reload();";
                                                            })
                                                            
                                                            )
                                                            )
                                                            )
                                                              
                                                              
        </form>
    var validation = function () {
        if (Ext.getCmp("f").isValid() == true) {
            return true;
        }
        else {
            return false;
        }
    }


    Code In controller

     public void save()
            {
                if (X.GetCmp<FileUploadField>("fuCompany_Logo_path").HasFile == true)
                {
                    string s = string.Empty;
                }
            }

    Above code i write for upload file.but the HasFile property is always getting false.can you please let me know what is wrong there?
    Last edited by Daniil; Jun 20, 2014 at 4:21 AM. Reason: [CLOSED]
  2. #2
    i change in controller
          public ActionResult save()
            {
                if (this.GetCmp<FileUploadField>("fuCompany_Logo_path").HasFile == true)
                {
                    string s = string.Empty;
                }
                return this.Direct();
            }
    and follow http://mvc.ext.net/#/Form_FileUploadField/Basic/ but still now not get any thing.
    Last edited by geoffrey.mcgill; Jun 16, 2014 at 4:33 AM.
  3. #3
    Hi,

    Please remove:
    de.Click.FormID = "fileUpload"
    The FileUploadField is not rendered to that form. Also I would recommend not to place a Window into a FormPanel's Items.

    Also, please remove
    de.Click.Before = "return validation();";
    and add
    .Listeners(l => l.Click.Handler = "return validation();")
    for the Button.

    A DirectEvent's Before doesn't work well in a case with a FileUploadField.
  4. #4
    Quote Originally Posted by Daniil View Post
    Hi,

    Please remove:
    de.Click.FormID = "fileUpload"
    The FileUploadField is not rendered to that form. Also I would recommend not to place a Window into a FormPanel's Items.

    Also, please remove
    de.Click.Before = "return validation();";
    and add
    .Listeners(l => l.Click.Handler = "return validation();")
    for the Button.

    A DirectEvent's Before doesn't work well in a case with a FileUploadField.
    Daniil as per your suggestion I write bellow code but still HasFile property is false

    @using Ext.Net.MVC
    @using Ext.Net
    
    @{
        ViewBag.Title = "Confirm MessageBox with ButtonsConfig - Ext.NET MVC Examples";
        Layout = null;
        var X = Html.X();
    }
    <script>
        var validation = function () {
            
            if (Ext.getCmp("f").isValid() == true) {
                return true;
            }
            else {
                return false;
            }
        }
    
    </script>
    @X.ResourceManager()
    
    @(
    
     X.Window()
                .ID("Window1")
                .Title("Add/Edit Material Category")
                .Width(560)
                .Plain(true)
                .Padding(5)
                .Resizable(false)
                
                .Hidden(false)
                .ButtonAlign(Alignment.Right)
                .Modal(true)
                
                .Items
                (
    
                     X.Panel().Height(50).Border(false).Layout(LayoutType.Table).LayoutConfig(new TableLayoutConfig { Columns = 2 })
                        .Items(
               X.Image().Height(50).Width(50),
               X.Label().Text("Some content Here")
                        ),
    
             //FORM PANEL START
                                                    X.FormPanel().BodyStyle("background-color: #F1F1F1;")
                                                    .ID("f")
                                                    .BodyPadding(5)
                                                    .Border(false)
    
                                                    .Items
                                                    (
                                X.TabPanel().Border(false).BodyStyle("background-color: #F1F1F1;")
                                    .Items(
            // TAB PERSONAL INFORMATION
    
                                        X.Panel().Width(550).Padding(5).Layout(LayoutType.VBox).LayoutConfig(new VBoxLayoutConfig { Align=VBoxAlign.Stretch})
                                        .Title("Personal Information").BodyStyle("background-color: #F1F1F1;").Border(false).Icon(Icon.UserGrayCool)
                                            .Items
                                                (
    
    
                                                            X.TextField()
                                                            .ID("txtWebSite")
                                                            .FieldLabel("WebSite")
                                                            .AnchorHorizontal("100%")
                                                            .EmptyText("WebSite")
                                                            .AllowBlank(false)
                                                            ,
                                                            X.FileUploadField()
                                                            .Icon(Icon.Attach)
                                                            .ID("fuCompany_Logo_path")
                                                            .FieldLabel("Company Logo")
                                                            .AnchorHorizontal("100%")
                                                            .EmptyText("Company Logo")
                                                              .AllowBlank(false)
    
    
                                                )
    											)
    											)
    											)
    											.Buttons(
                                                             X.Button()
                                                            .Text("Save")
                                                            .ID("btnSave")
                                                            .Listeners(l => l.Click.Handler = "return validation();")
          
                                                            .DirectEvents(de =>
                                                            {
                                                               
                                                                de.Click.Action = "save";
                                                                de.Click.EventMask.ShowMask = true;
                                                                de.Click.EventMask.Msg = "Saving...";
                                                                de.Click.EventMask.MinDelay = 100;
                                                                //de.Click.After = "App.GridPanel1.getStore().reload();";
                                                            })
                                                )
    											)
    CONTROLLER

    public ActionResult save()
            {
                if (this.GetCmp<FileUploadField>("fuCompany_Logo_path").HasFile == true)
                {
                    string s = string.Empty;
                }
                return this.Direct();
            }
    Last edited by matrixwebtech; Jun 17, 2014 at 6:14 AM.
  5. #5
    Now you have a bit different configuration.

    I can suggest the following.

    Replace the Panel (that contains the TextField and FileUploadField) with a FormPanel with
    .ID("FormPanel1")
    Then set
    de.Click.FormID = "FormPanel1";
    for the Click DirectEvent.

Similar Threads

  1. [CLOSED] FileUploadField1.HasFile alway false
    By tobros in forum 2.x Legacy Premium Help
    Replies: 6
    Last Post: Jun 13, 2013, 11:06 AM
  2. Replies: 8
    Last Post: Jun 10, 2013, 1:06 PM
  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: 0
    Last Post: Mar 02, 2012, 1:11 PM
  5. Replies: 1
    Last Post: Jun 23, 2011, 9:37 AM

Tags for this Thread

Posting Permissions