1 /* System.Web.UI.HtmlControls
\r
3 * Leen Toelen (toelen@hotmail.com)
\r
7 using System.ComponentModel;
\r
10 using System.Globalization;
\r
11 using System.Collections.Specialized;
\r
13 namespace System.Web.UI.HtmlControls{
\r
14 [ValidationProperty("Value")]
\r
15 public class HtmlInputFile : HtmlInputControl, IPostBackDataHandler{
\r
17 public HtmlInputFile():base("file"){}
\r
19 bool IPostBackDataHandler.LoadPostData (string postDataKey,
\r
20 NameValueCollection postCollection)
\r
25 void IPostBackDataHandler.RaisePostDataChangedEvent ()
\r
30 [WebCategory("Behavior")]
\r
31 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
\r
32 public string Accept{
\r
34 string attr = Attributes["accept"];
\r
37 return String.Empty;
\r
40 Attributes["accept"] = AttributeToString(value);
\r
45 [WebCategory("Behavior")]
\r
46 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
\r
47 public int MaxLength{
\r
49 string attr = Attributes["maxlength"];
\r
51 return Int32.Parse(attr, CultureInfo.InvariantCulture);
\r
55 Attributes["maxlength"] = AttributeToString(value);
\r
60 [WebCategory("Appearance")]
\r
61 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
\r
64 string attr = Attributes["size"];
\r
66 return Int32.Parse(attr, CultureInfo.InvariantCulture);
\r
70 Attributes["size"] = AttributeToString(value);
\r
75 [WebCategory("Misc")]
\r
76 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
\r
77 public HttpPostedFile PostedFile{
\r
79 return Context.Request.Files[RenderedName];
\r
83 protected override void OnPreRender (EventArgs e)
\r
85 base.OnPreRender (e);
\r
86 for (Control ctrl = this.Parent; ctrl != null && !(ctrl is Page); ctrl = ctrl.Parent) {
\r
87 if (!(ctrl is HtmlForm))
\r
90 HtmlForm form = (HtmlForm) ctrl;
\r
91 if (form.Enctype == "")
\r
92 form.Enctype = "multipart/form-data";
\r
98 public override string Value {
\r
100 HttpPostedFile file = PostedFile;
\r
104 return file.FileName;
\r
108 throw new NotSupportedException ();
\r
113 } // class HtmlInputFile
\r
114 } // namespace System.Web.UI.HtmlControls
\r