Problem solve Get help with specific problems with your technologies, process and projects.

Using the File Field control to upload files

Using the File Field control to upload files.

The Microsoft ASP.NET File Field control permits end users to upload one or more files from their desktops to your servers. A recent article in the MS Visual Studio Developer Center provides all the gory details about this tool including code samples, but I provide a 10,000-foot view and some interesting pointers here.

ASP.NET Web forms are designed to permit communications with end users about the kind of data they must supply to perform specific tasks, or to interact with various custom applications. When such interactions involve data that is not simple text, a file upload control can be of significant value to developers. That's why ASP.NET makes it easy to upload files or documents to a server, and where the File Field control comes into play.

The File Field control makes use of the HtmlInputFile class, and supplies mechanisms to control file uploads to a server from client computers. This control is named File Field in versions of Visual Studio.NET, but is known as the FileUpload control in the ASP.NET Web matrix. Either way, you'll find this control in the HTML section of the Toolbox you'll use.

Simply put, the File Field control permits the HTML <input type="file"> element to be programmed, and is used to identify file data within an HTML form. Previous implementations of ASP.NET often required third-party tools to handle this job, but with access to .NET environment and the File Field control, uploading is a piece of cake. The Visual Studio Developer Center article provides detailed code listings that show exactly how to use this control in Visual Basic and Visual C#.

If that code is used, it permits easy selection and upload controls for files simply by clicking an Upload File button on a Web page that includes that code. The MS article also explains how to set file permissions to make sure that end users can deposit files in whatever target directory you specify. It's great when MS makes such important, frequently used activities so easy to include in your code. Check out the article and code samples and you'll see just how simple and straightforward this really is!


Ed Tittel is a full-time writer and trainer whose interests include XML and development topics, along with IT Certification and information security topics. E-mail Ed at etittel@lanw.com with comments, questions, or suggested topics or tools to review.


Dig Deeper on ASP.NET development best practices

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchCloudComputing

SearchSoftwareQuality

TheServerSide.com

Close