NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

HtmlInputFile Class

The HtmlInputFile class defines the methods, properties, and events for the HtmlInputFile control. This class allows programmatic access to the HTML <input type= file> element on the server. It provides access to the NGWS runtime stream, as well as a useful SaveAs functionality provided by the PostedFile property.

CAUTION   This class only works if the HtmlForm.Enctype property is set to "multipart/form-data". Also, it does not maintain its state across multiple round trips between browser and server. If the user sets this value after a round trip, the value is lost.

Object
   Control
      HtmlControl
         HtmlInputControl
            HtmlInputFile

[Visual Basic]
Public Class HtmlInputFile
   Inherits HtmlInputControl
   Implements IPostBackDataHandler
[C#]
public class HtmlInputFile : HtmlInputControl, IPostBackDataHandler
[C++]
public __gc class HtmlInputFile : public HtmlInputControl,
   IPostBackDataHandler
[JScript]
public class HtmlInputFile extends HtmlInputControl,
   IPostBackDataHandler

Remarks

Web developers can utilize the HtmlInputFile server control to handle uploading binary or text files from a browser client to the server. File-upload works with Microsoft Internet Explorer 3.02 and above, as well as Netscape 3.0 and above.

Requirements

Namespace: System.Web.UI.HtmlControls

Assembly: System.Web.dll

Example [Visual Basic]

This example shows a simple file upload scenario.

[Visual Basic]

<html>
   <script runat=server>
      Sub FileUploadBtn_Click(Source As Object, ByVal E as EventArgs)
           If (Not IsNull(MyFile.PostedFile)) 
Then MyFile.PostedFile.SaveAs("c:\temp\File1.dat")
           End If
      End Sub
    </script>
 
    <body>
      <form enctype="multipart/form-data" runat=server>
          Select File to Upload:  
  <input id="MyFile" type=file runat=server> <br><br>
  <input type=button value="Upload" OnServerClick="FileUploadBtn_Click" runat=server>
       </form>
    </body>
</html>

See Also

HtmlInputFile Members | System.Web.UI.HtmlControls Namespace | HttpPostedFile