Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

calling C# function immediately file is selected in fileupload

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 ?

like image 892
Arjun Chiddarwar Avatar asked Mar 10 '13 19:03

Arjun Chiddarwar


People also ask

What is calling function in C?

Function Calling: A function call is an important part of the C programming language. It is called inside a program whenever it is required to call a function. It is only called by its name in the main() function of a program. We can pass the parameters to a function calling in the main() function.

Is there a language called C --?

C is a general purpose computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system. It was named 'C' because many of its features were derived from an earlier language called 'B'.

What is call value in C?

The call by value method of passing arguments to a function copies the actual value of an argument into the formal parameter of the function. In this case, changes made to the parameter inside the function have no effect on the argument. By default, C programming uses call by value to pass arguments.

How do you call C in C++?

Just declare the C++ function extern "C" (in your C++ code) and call it (from your C or C++ code). For example: // C++ code: extern "C" void f(int);


1 Answers

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;
    }
 }
like image 66
meer Avatar answered Sep 17 '22 15:09

meer