Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FileUpload inside jquery dialog, hasfile false

I have a jquery UI dialog on my page. It contains nothing more than a single asp FileUpload control:

<asp:FileUpload runat="server" ID="fuAttachment" />

The dialog has 1 button "OK". Those button simply closes the dialog

$("#attachment-dialog").dialog({
            height: 300,
            width: 400,
            modal: true,
            resizable: false,
            autoOpen: false,
            buttons: {
                "OK": function () {
                    $(this).dialog("close");
                }
            }
  });

When pressing the save button on my page. Which is an asp.net button the method SaveAttachement is called.

The problem is that fuAttachment.HasFile (the fileupload control) keeps returning false. If I move the fileupload control outside of the jQuery UI dialog. HasFile = true.

But the control should be inside the dialog. There's no updatepanel inside the specific page.

like image 586
neuzehie Avatar asked Feb 18 '26 03:02

neuzehie


1 Answers

The problem is happening because the dialog is outside of the form.

jQuery UI Dialog has an appendTo parameter that will ensure the dialog is part of the form.

$("#attachment-dialog").dialog({
            appendTo: "form",
            height: 300,
            width: 400,
            modal: true,
            resizable: false,
            autoOpen: false,
            buttons: {
                "OK": function () {
                    $(this).dialog("close");
                }
            }
  });
like image 91
mason Avatar answered Feb 19 '26 15:02

mason



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!