FileUpload Constructor

Note: This constructor is new in the .NET Framework version 2.0.

Initializes a new instance of the FileUpload class.

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

public:
FileUpload ()
public FileUpload ()
public function FileUpload ()

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.

The following code 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 code example is part of a larger example provided for the FileUpload class.

<%@ Page Language="VB" %>

<html>
<head>

    <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.
            PlaceHolder1.Controls.Add(FileUpload1)
            
        End Sub
       
    </script>

</head>
<body>

    <h3>FileUpload Constructor Example</h3>

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

         <asp:Button id="Button1" 
             Text="Create and show a FileUpload control" 
             OnClick="Button1_Click" 
             runat="server"/>    	      
         
    </form>

</body>
</html>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show: