FileUpload Control
Previous | Home | Next |
The File Upload control enables the user in uploading text files,pictures.This control ususly display the text box,where type the file name which we want to upload in the server.This control also display the a Browse button that helps in display file navigation dialog box.Using Dialog Box,can select the desire file that want to be uploaded. Some properties: 1.FileBytes 2.FileContent 3.FileNAme 4.HasFile 5.PostedFile
SaveAS:Save The Content of Upload File to a specified location on server.
HasFile::Obtains a value indicating whether the FileUpload control contains a file or not.
FileUpload Control Code ********************************************************************** <%@ Page Language="C#" AutoEventWireup="true" CodeFile="FileUpload.aspx.cs" Inherits="_Default" %>How To Use ************************************************************************** using System; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!(Page.IsPostBack)) { Label2.Text = ""; } } protected void Button1_Click(object sender, EventArgs e) { if (FileUpload1.HasFile) { FileUpload1.SaveAs("D:\\" + FileUpload1.FileName); Label2.Text = "File Uploaded"; } else { Label2.Text="No File Uploaded"; } } }FileUpload Control
Previous | Home | Next |