Class McHtmlInputFile
Control that allows to simplify and optimize file uploading using web browser to your ASP.NET Web Server.
Inheritance
Implements
Namespace: Mediachase.FileUploader.Web.UI
Assembly: Mediachase.FileUploader.dll
Version: 10.8.0Syntax
public class McHtmlInputFile : WebControl, IPostBackDataHandler
Remarks
You should use the McHtmlInputFile server control instead of System.Web.UI.HtmlControls.HtmlInputFile. Use the McHtmlInputFile server control to handle uploading binary or text files from a browser client to the server. File upload works with Microsoft Internet Explorer version 3.02 or later.
note
The Enctype property of an HtmlForm must be set to "multipart/form-data" for this control to work properly
To specify the file to upload, enter the fully path to the file (for example, "C:\MyFiles\Test.txt") in the text box of the control. You can also select the file by clicking the Browse button and then locating it in the Choose file dialog box.
The McHtmlInputFile control does not have a built-in way to post back to the server. To upload the file to the server, use the SaveAs(String) method of the McHttpPostedFile contained in the PostedFile property. This operation is usually done in an event-handling method, such as for a button click.
To simplify development Mediachase.FileUploader.Web.UI.McHtmlFileInput supports full Design-Time view in Visual Studio.NET. You can add it into Visual Studio.NET toolbar and then add it to your webform using drag-and-drop. You can change properties and control will adjust in real-time it's view to the one that will be displayed on web page.
note
To add the control to the Visual Studio .NET toolbox, please do the following:
- Open a Web Form (aspx page) in design mode.
- Right-click on the toolbox.
- Select Customize Toolbox.
- Select the .NET Framework Components tab.
- Click Browse....
- Find Mediachase.FileUploader.dll on your local machine, and select Open.
Constructors
McHtmlInputFile()
Initializes a new instance of the McHtmlInputFile class.
Declaration
public McHtmlInputFile()
Remarks
Use this constructor to create and initialize a new instance of the McHtmlInputFile class.
Properties
Accept
Gets or sets a comma-separated list of MIME encodings used to constrain the file types the user can select.
Declaration
public string Accept { get; set; }
Property Value
Type | Description |
---|---|
System.String | The comma-separated list of MIME encodings. |
Remarks
Use this property to specify the file type that can be uploaded to the server. For example, to restrict the selection to images, set this property to "image/*".
note
Support for this property is browser dependent. Check with your browser to determine if it supports this property.
HasFile
Gets a value indicating whether the control contains a file.
Declaration
public virtual bool HasFile { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
MaxLength
Gets or sets the maximum length of the file path for the file to upload from the client computer.
Declaration
public int MaxLength { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The maximum length of the file path. |
Remarks
Use this property to specify a limit for the number of characters that can be entered for the path to the file to upload.
note
Support for this property is browser dependent. Check with your browser to determine if it supports this property.
MultiFileCount
Gets or sets the count of the multi-file that can be sent at the same time. 0 - is unlimited
Declaration
public int MultiFileCount { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The size of the multi file. |
MultiFileUpload
Gets or sets an ability to upload multiple files at once.
Declaration
public bool MultiFileUpload { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
PostedFile
Gets access to the uploaded file specified by a client.
Declaration
public McHttpPostedFile PostedFile { get; }
Property Value
Type | Description |
---|---|
McHttpPostedFile | A McHtmlInputFile that accesses the file to be uploaded. |
Remarks
Browser security restrictions prevent this value from being maintained across multiple requests.
PostedFiles
Gets access to the uploaded files specified by a client.
Declaration
public McHttpPostedFile[] PostedFiles { get; }
Property Value
Type | Description |
---|---|
McHttpPostedFile[] | A McHtmlInputFile collection that accesses the files to be uploaded. |
RenderedNameAttribute
Gets the unique, hierarchically-qualified name.
Declaration
public virtual string RenderedNameAttribute { get; }
Property Value
Type | Description |
---|---|
System.String |
Separator
Gets or sets the multi-file html separator.
Declaration
public string Separator { get; set; }
Property Value
Type | Description |
---|---|
System.String | The separator. |
Size
Gets or sets the width of the text box in which the file path is entered.
Declaration
public int Size { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The width of the file-path text box. |
Remarks
Use this property to specify the width of the text box in which to enter the file path.
Value
Gets the full path of the file on the client's computer.
Declaration
public virtual string Value { get; set; }
Property Value
Type | Description |
---|---|
System.String | The full path of the client's file. |
Remarks
The Value property retrieves the full path of the file on the client's computer (for example "C:\MyFiles\Test.txt"). This is useful when you need to know where the file is stored on the computer submitting the file. This property is also commonly used to determine the original file name. To get the original file name, parse the value of this property.
note
The Value property is read-only. If you attempt to assign a value to this property, a System.NotSupportedException is thrown.
ViewStateIgnoresCase
This member overrides System.Web.UI.Control.ViewStateIgnoresCase.
Declaration
protected override bool ViewStateIgnoresCase { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
AddAttributesToRender(HtmlTextWriter)
This member overrides System.Web.UI.WebControls.WebControl.AddAttributesToRender(System.Web.UI.HtmlTextWriter)
Declaration
protected override void AddAttributesToRender(HtmlTextWriter writer)
Parameters
Type | Name | Description |
---|---|---|
System.Web.UI.HtmlTextWriter | writer |
CreateChildControls()
This member overrides System.Web.UI.Control.CreateChildControls
Declaration
protected override void CreateChildControls()
CreateControlCollection()
This member overrides System.Web.UI.Control.CreateControlCollection
Declaration
protected override ControlCollection CreateControlCollection()
Returns
Type | Description |
---|---|
System.Web.UI.ControlCollection |
OnInit(EventArgs)
Declaration
protected override void OnInit(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e |
OnPreRender(EventArgs)
This member overrides System.Web.UI.Control.OnPreRender(System.EventArgs)
Declaration
protected override void OnPreRender(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e |
Render(HtmlTextWriter)
This member overrides System.Web.UI.WebControls.WebControl.Render(System.Web.UI.HtmlTextWriter)
Declaration
protected override void Render(HtmlTextWriter writer)
Parameters
Type | Name | Description |
---|---|---|
System.Web.UI.HtmlTextWriter | writer |
RenderContents(HtmlTextWriter)
Renders the contents of the control to the specified writer. This method is used primarily by control developers.
Declaration
protected override void RenderContents(HtmlTextWriter writer)
Parameters
Type | Name | Description |
---|---|---|
System.Web.UI.HtmlTextWriter | writer | A System.Web.UI.HtmlTextWriter that represents the output stream to render HTML content on the client. |