开发者

ASP.Net Ajax AsyncFileUpload control not firing server side OnUploadCompleted event

开发者 https://www.devze.com 2022-12-08 18:45 出处:网络
I am writing an application that requires a user to upload files to the server machine. All user interaction with the user is done via JQuery UI modal popups. I created a test page to see that the Asy

I am writing an application that requires a user to upload files to the server machine. All user interaction with the user is done via JQuery UI modal popups. I created a test page to see that the AsyncFileUpload control works, and everything works fine on it. I added the AsyncFileUpload to the webform that I need it on, in a modal popup, but for some reason the server side event is never fired.开发者_开发知识库 The only difference on this page from the test page is that I send a variable through on the querystring which I, on initial load of the page, store in the viewstate (so it isn't required on future postbacks). Any ideas?

Thanks


When you use AsyncFileUpload you must set the right params in the "form" tag, that is placed in your Page or MasterPage:

 <form id="form1" runat="server" enctype="multipart/form-data" method="post">

If you don't set the right enctype and method UploadedComplete will never fire, and you won't be able to get FileUpload.FileBytes since FileUpload.HasFile returns true only during UploadedComplete execution.

I suppose that you didn't set the correct enctype on your modal popup.

Besides, prevoius versions of AsyncFileUpload didn't work on Chrome. Actual version (4.1.50731.0) solved the problem.


When dealing with AsyncFileUpload Control's Event, store any data in Session state instead of viewstate.

0

精彩评论

暂无评论...
验证码 换一张
取 消