[CLOSED] FileUploadField in a ToolBar

  1. #1

    [CLOSED] FileUploadField in a ToolBar

    Hi,

    I'm having a bit of trouble getting a FileUploadField to work inside an ext:ToolBar.

      <ext:FileUploadField ID="statementFile" runat="server" EmptyText="Select a scanned statement file"
                                    Width="300" CtCls="button-fix" IsFormField="true">
                                    <Listeners>
                                        <FileSelected Handler="var b=#{btnUploadStatement};b.enable();" />
                                    </Listeners>
      /ext:FileUploadField>
    But when I post back to the controller, the Request.Files array is empty:

     [AcceptVerbs(HttpVerbs.Post)]
            public ActionResult Upload() {
                HttpPostedFileBase postedFile = Request.Files[0];
                ........
            }
    I read in the post here that you need to wrap it in a form to make it work; but in this post, here it indicates it is possible in a toolbar just as I have tried.

    Which is correct? Is their something else I should do to properly have it submit?

    Cheers.
    Last edited by Daniil; May 17, 2011 at 2:02 PM. Reason: [CLOSED]
  2. #2
    Hi,

    I guess Vladimir forgot to add <form> in that example, because there was problem in css.

    So, <form> is definitely required.
  3. #3
    Thanks. This almost works; it will now try and download the file, however, (in IE8; our target platform) when I click on the button that submits the form it does upload.. but then tries to download the file itself again.

    My upload button:

     <ext:Button ID="btnUploadStatement" runat="server" Disabled="true" Icon="Attach"
                                    Text="Upload Statement" ToolTip="Uploads the chosen file to the server for processing.">
                                    <DirectEvents>
                                        <Click IsUpload="true" Method="POST" Url="/Commission/Upload/" Failure="SaveAndInvest.alertBox('Error', result.errorMessage)" />
                                            <EventMask ShowMask="true" Msg="Uploading file.." />
                                        </Click>
                                    </DirectEvents>
                                </ext:Button>
    The part of code causing this seems to be:

     public override void ExecuteResult(ControllerContext context)
            {
                if (this.IsUpload)
                {
                    context.HttpContext.Response.Write("<textarea>{0}</textarea>".FormatWith(new ClientConfig().Serialize(this)));
                }
               .....
    Any ideas why it tries to download after uploading?
  4. #4
    The answer is in the thread you mentioned.
    http://forums.ext.net/showthread.php?10582

    Set up .IsUpload = true for AjaxResult.

Similar Threads

  1. [CLOSED] [1.0] FileUploadField in toolbar does not render
    By jchau in forum 1.x Legacy Premium Help
    Replies: 9
    Last Post: Dec 12, 2011, 5:43 PM
  2. Replies: 7
    Last Post: May 25, 2011, 9:35 AM
  3. Replies: 1
    Last Post: Mar 07, 2011, 9:39 AM
  4. Replies: 0
    Last Post: Feb 01, 2010, 5:44 AM
  5. Adding FileUploadField in toolbar
    By n_s_adhikari@rediffmail.com in forum 1.x Help
    Replies: 2
    Last Post: Aug 11, 2009, 4:21 PM

Tags for this Thread

Posting Permissions