Fix issue file not upload to server with Multiview + File Upload + UpdatePanel - asp.net

Recently I have developed some modules to upload the file to the server. In my code, I have an update panel and also the multiview. Somehow the upload not working. So I thought I was not set the full postback for the upload process in the trigger section under the update panel. But actually, the full postback was set correctly. So I wonder, why the upload not working. 

So I start to investigate my code, and luckily I found the solution.

The solution 

I just need to set enctype attribute at the form and value multipart/form-data.

This is the code I use.


   protected override void OnInit(EventArgs e)  
{
base.OnInit(e);
Page.Form.Attributes.Add("enctype", "multipart/form-data");
}

Hopefully, this simple solution helps someone.



Popular posts from this blog

Example to disable save as certain file type in SSRS Report Viewer

How to create DataGrid or GridView in JSP - Servlet

Control Webpart Visible/Enable using macro in Kentico