FileUpload FileUpload FileUpload Constructor


Initializes a new instance of the FileUpload class.

public FileUpload ();
Public Sub New ()


The following example demonstrates how to initialize a new instance of the FileUpload class. Note that this example demonstrates the constructor syntax but does not add functionality to the control after it is created.

This example is part of a larger example provided for the FileUpload class.

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="" >
    <title>FileUpload Constructor Example</title>
<script runat="server">
        Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
            ' Create a FileUpload control.
            Dim FileUpload1 As New FileUpload
            ' Add the FileUpload control to the Controls collection
            ' of the PlaceHolder control.
        End Sub


    <h3>FileUpload Constructor Example</h3>

    <form id="Form1" runat="server">
        <asp:PlaceHolder id="PlaceHolder1"                 
        <hr />

         <asp:Button id="Button1" 
             Text="Create and show a FileUpload control" 



Use the FileUpload constructor to initialize a new instance of the FileUpload class. The FileUpload control does not automatically save a file to the server after the user selects the file to upload. You must explicitly provide a control or mechanism to allow the user to submit the specified file. For example, you can provide a button that the user clicks to upload the file.

Applies to