[CLOSED] how to batch upload ?

  1. #1

    [CLOSED] how to batch upload ?

    I create a modal window which contains several panels in codebehind , each panel have 3 textfields and a upload control.
    a button in the page, when click the button , how to get the textfields 's value and upload the upload control's file in codebehind.
    below is my example code:
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="TobrosCWT.pages.pingzheng.WebForm1" %>
    
    <script runat="server">
        private Ext.Net.Panel GetPanel(int index)
        {
            return new Ext.Net.Panel()
            {
                Title = "附件" + index,
                Items = 
                    {
                        new TextField() { FieldLabel = "附件名称" },   
                        new TextField() { FieldLabel = "附件描述" },
                        new TextField() { FieldLabel = "其他描述" },
                        new FileUploadField(){FieldLabel="附件",Icon=Ext.Net.Icon.ImageAdd,ButtonText=""}
                    }
            };
        }
        protected void e_upload(object sender, DirectEventArgs e)
        {
            // X.Msg.Alert("ssss", "dddd").Show();
            //here, how to get Window1's items which Dynamic Created by NumberField1_IconClick.
            // and loop the items,get three textfields'value and upload the fileuploadfield in each loop.
            // can you give me an example code?
        }
        protected void NumberField1_IconClick(object sender, DirectEventArgs e)
        {
            int currentCount = int.Parse(e.ExtraParams["currentCount"]);
            int neededCount = (int)this.NumberField1.Number;
            int panelsToAdd = neededCount - currentCount;
    
            if (panelsToAdd > 0)
            {
                for (int i = 1; i <= panelsToAdd; i++)
                {
                    this.GetPanel(i + currentCount).AddTo(this.Window1);
                }
            }
            else if (panelsToAdd < 0)
            {
                X.Js.Call("removeFrom", this.Window1.ConfigID, -panelsToAdd, currentCount);
            }
    
            this.Window1.Show();
        }
    </script>
    
    <!DOCTYPE html>
    <html>
    <head id="Head1" runat="server">
        <title>Ext.NET v2 Example</title>
    
        <script type="text/javascript">
            var removeFrom = function (win, countToRemove, totalCount) {
                win = App[win];
    
                var items = win.items;
    
                Ext.suspendLayouts();
                for (var i = 1; i <= countToRemove; i++) {
                    win.remove(items.getAt(totalCount - i));
                }
    
                Ext.resumeLayouts(true);
    
                if (win.items.length > 0)
                    win.items.first().getBody().el.setVisible(true);
            };
        </script>
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
            <ext:Viewport runat="server" Layout="TableLayout">
                 
                <Items>
                    <ext:Window
                        ID="Window1"
                        runat="server"
                        Width="300"
                        Height="300"
                        Hidden="true"
                        Layout="AccordionLayout" />
                    <ext:NumberField ID="NumberField1" runat="server" Icon="Add">
                        <DirectEvents>
                            <IconClick OnEvent="NumberField1_IconClick">
                                <ExtraParams>
                                    <ext:Parameter Name="currentCount" Value="App.Window1.items.getCount()" Mode="Raw" />
                                </ExtraParams>
                            </IconClick>
                        </DirectEvents>
                    </ext:NumberField>
                    <ext:Button ID="Button1" runat="server" Text="upload">
                        <DirectEvents>
                            <Click OnEvent="e_upload"></Click>
                        </DirectEvents>
                    </ext:Button>
    
                </Items>
            </ext:Viewport>
    
    
    
        </form>
    </body>
    </html>
    Last edited by Daniil; Jun 18, 2013 at 3:51 AM. Reason: [CLOSED]
  2. #2
    Hi @tobros,

    You can achieve your requirement this way.
    TextField textField1 = X.GetCmp<TextField>("TextField1");
    string value1 = textField.Text;
    
    TextField textField2 = X.GetCmp<TextField>("TextField2");
    string value2 = textField.Text;
    
    FileUploadField fileUploadField = X.GetCmp<FileUploadField>("FileUploadField1");
    HttpPostedFile file = fileUploadField.PostedFile;
    So, you need the fields' ids.

    Please note that an X.GetCmp feature is just a convenience way to access POST values. You can access it direct from a Request object if you wish.

    Also please note that you can't iterate dynamic controls, if you don't recreate those controls. In your scenario it looks possible not to recreate the controls.

Similar Threads

  1. [CLOSED] Batch Update Issue
    By shaileshsakaria in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Apr 03, 2013, 7:08 AM
  2. Batch Update
    By shaileshsakaria in forum 2.x Help
    Replies: 1
    Last Post: Jan 18, 2013, 4:17 PM
  3. [2.1] GridPanelFor Batch Update
    By millenovanta in forum 2.x Help
    Replies: 20
    Last Post: Dec 26, 2012, 12:27 PM
  4. [CLOSED] MVC Grid Batch Editing
    By adelaney in forum 2.x Legacy Premium Help
    Replies: 19
    Last Post: Sep 27, 2012, 5:55 AM
  5. Replies: 1
    Last Post: Jun 23, 2011, 9:37 AM

Posting Permissions