use the ASP.NET button control which the the user will click to upload the file he has selected using the file control. As ASP.NET follows event based programming model we can attach a server side event which will respond to clicking of the button. This is done by using the OnClick event handler of the button control. To this event we assign the name of the method which we want to be executed on the server when the user clicks the button. (e.g)
Code:
<asp:button id="cmdUpload" name="cmdUpload" runat="server" OnClick="UploadFile" />
Now we can write C# code within the UploadFile method to save the uploaded file in the server. This code can be written in two ways depending on the number of file controls we have within the page. If there is only a single file control then we can use the PostedFile property of the file control to upload files.
Bookmarks