web| Control | upload | upload control using System;
Using System.Web.UI;
Using System.Web.UI.WebControls;
Using System.ComponentModel;
Using System.Web.UI.HtmlControls;
Using System.IO;
Using System.Drawing;
Using System.Drawing.Design;
Namespace Yingnet.common
{
<summary>
Summary description of the fileupload. E:\program\Common\FileUpload.bmp
</summary>
[ToolboxBitmap (typeof (Yingnet.Common.FileUpload), "Fileupload.bmp"),
Defaultproperty ("Text"), DefaultEvent ("click"),
ToolBoxData ("<{0}:fileupload runat=server></{0}:fileupload>")]
public class FileUpload:System.Web.UI.WebControls.WebControl {
<summary>
Upload button
</summary>
Private button Button=new button ();
<summary>
Number of uploaded files
</summary>
private int filenum=1;
<summary>
File Object
</summary>
Private htmlinputfile[] file;
<summary>
Save path, default to System temp directory
</summary>
private string Path=system.io.path.gettemppath ();
<summary>
Uploaded file name group
</summary>
Private string[] filename;
<summary>
Suffix file name Group
</summary>
Private string[] suffix;
<summary>
Filter, the writing is txt;. Abc
</summary>
private string Filter= "";
<summary>
Limit file upload size, 0 is unrestricted, unit is byte
</summary>
private int Size=0;//system.componentmodel.defaulteventattribute
<summary>
Uploading events
</summary>
[Bindable (True), Category ("event"), Description ("Events fired after upload")
]
public event EventHandler Click;
<summary>
Number of files uploaded
</summary>
[Bindable (True),
Category ("Parameters"), Description ("set the number of uploaded files"),
DefaultValue ("1")]
public int filenum{
set{
if (value<1) {
value=1;
}
Filenum=value;
This. Controls.clear ();
File=new Htmlinputfile[filenum];
Filename=new String[filenum];
Suffix=new String[filenum];
for (int i=0;i<filenum;i++) {
File[i]=new HtmlInputFile ();
This. Controls.Add (File[i]);
}
This. Controls.Add (button);
}
get{
return filenum;
}
}
<summary>
Text of the Upload button
</summary>
[Bindable (True),
Category ("Parameters"), Description ("Set the path of the uploaded file"),
DefaultValue ("1")]
<summary>
Upload path
</summary>
public string Uploadpath {
set{
if ("". Equals (value) | | Value==null) {
Value=system.io.path.gettemppath ();
}
Path=value;
}
get{
return path;
}
}
<summary>
Get file name
</summary>
Public string[] Filename{
get{
return filename;
}
}
<summary>
Get suffix
</summary>
Public string[] Suffix{
get{
return suffix;
}
}
<summary>
Filtering device
</summary>
public string filter{
set{
Filter=value;
}
get{
return filter;
}
}
<summary>
Limit size
</summary>
public int filesize{
set{
Size=value;
}
get{
return size;
}
}
<summary>
Shortcut keys
</summary>
public override string accesskey{
get{
Return button. AccessKey;
}
set{
button. Accesskey=value;
}
}
<summary>
Background
</summary>
public override System.Drawing.Color backcolor{
get{
Return button. BackColor;
}
set{
button. Backcolor=value;
}
}
<summary>
Border color
</summary>
public override System.Drawing.Color bordercolor{
get{
Return button. bordercolor;
}
set{
button. Bordercolor=value;
}
}
<summary>
Border Style
</summary>
public override BorderStyle borderstyle{
get{
Return button. BorderStyle;
}
set{
button. Borderstyle=value;
}
}
<summary>
Text
</summary>
[Bindable (True),
Category ("appearance"),
DefaultValue ("")]
public string Text
{
Get
{
Return button. Text;
}
Set
{
button. Text = value;
}
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.