Introduction
FileUpload Control is used to upload any
picture or any file in application. It provide a text box control, a browse
button and a submit button. Browse button is used to select a file to upload on
server. Submit button is used to submit image or file in application.
System.Web.UI.WebControls namespace is provide
this feature in program and it found in System.Web (in System.Web.dll) assembly.
Properties
- AccessKey
- Adapter
- AppRelativeTemplateSourceDirectory
- Attributes
- BackColor
- BindingContainer
- BorderColor
- BorderStyle
- BorderWidth
- ChildControlsCreated
- ClientID
- ClientIDMode
- ClientIDSeparator
Code that are used in FileUpload Control
<asp:FileUpLoad id="File1" runat="server" />
<asp:Button id="UploadButton" Text="Upload
File" OnClick="UploadButton_Click" runat="server" />
.CS Code that are used in FileUpload Control
protected void UploadButton_Click(object sender, EventArgs e)
{
if (File1.HasFile)
{
File1.SaveAs(@"C:\vipendra\" +
File1.FileName);
Label1.Text = "File
Uploaded: " +
File1.FileName ;
}
else
{
Label1.Text = "No
File Uploaded.";
}
}