calling C# function immediately file is selected in fileupload

asp.net, file-upload

Solution

Try this

  <asp:FileUpload ID="FileUpload01" ClientIDMode="Static" onchange="this.form.submit()"   runat="server"/>

in code behind Page_load event

if (IsPostBack && FileUpload01.PostedFile != null)
{
   if (FileUpload01.PostedFile.FileName.Length > 0)
   {    
       FileUpload01.SaveAs(Server.MapPath("~/Images/") + FileUpload01.PostedFile.FileName);   
       imguser.ImageUrl = "~/Images/" + FileUpload01.PostedFile.FileName;
    }
 }

Problem

I have a web form(asp.net) which I'm using to upload file. In current situation if a user choose a text file from their computer they have to click a buttton to upload the text in a box. I'm trying to find a way to skip the step with a button pressing. How to call a C# function when the file is selected from user ?

Original source