Download an ASP.Net file with an empty assembly of files

I have an ASP.NET download control that is located as part of a form. The file upload control is located on the content page, while the form definition is on the main page on the site. I added multipart / form-enc to the form on the main page.

I am using jQuery to submit a form when I display a dialog from the jQuery user interface.

When I send a message, the file is not returned to the server. The file upload control does not have a file, and the HttpFileCollection is empty. How to find a published file?

+3
source share
1 answer

Most dialogs take your content, wrap it, and put the result directly in front of </body>the page ... this is a problem in ASP.Net because outside <form></form>it must be inside to be included in POSTed data.

When you create a dialog box, make it added internally <form>when it ends instead <body>, for example, this is what you would do with the jQuery UI dialog box :

$("#myDiv").dialog({ ...options... }).parent().appendTo("form:first");

Now that he has been moved inside <form>, he should post the message correctly.

+5
source

Source: https://habr.com/ru/post/1746876/


All Articles