2 // System.Web.UI.HtmlControls.HtmlInputFile.cs
5 // Dick Porter <dick@ximian.com>
7 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 using System.Collections.Specialized;
30 using System.ComponentModel;
31 using System.Security.Permissions;
33 namespace System.Web.UI.HtmlControls
36 [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
37 [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
39 [ValidationProperty ("Value")]
40 public class HtmlInputFile : HtmlInputControl , IPostBackDataHandler
42 public HtmlInputFile () : base ("file")
47 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
48 [WebSysDescription("")]
52 string acc = Attributes["accept"];
55 return (String.Empty);
62 Attributes.Remove ("accept");
64 Attributes["accept"] = value;
70 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
71 [WebSysDescription("")]
75 string maxlen = Attributes["maxlength"];
80 return (Convert.ToInt32 (maxlen));
85 Attributes.Remove ("maxlength");
87 Attributes["maxlength"] = value.ToString ();
92 HttpPostedFile posted_file;
95 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
96 [WebSysDescription("")]
98 public HttpPostedFile PostedFile
101 return (posted_file);
106 [DefaultValue ("-1")]
110 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
111 [WebSysDescription("")]
112 [WebCategory("Appearance")]
116 string size = Attributes["size"];
121 return (Convert.ToInt32 (size));
126 Attributes.Remove ("size");
128 Attributes["size"] = value.ToString ();
134 public override string Value
137 string value = Attributes["value"];
140 return (String.Empty);
146 throw new NotSupportedException ();
155 override void OnPreRender (EventArgs e)
157 base.OnPreRender (e);
160 Page.RegisterRequiresPostBack (this);
164 bool LoadPostDataInternal (string postDataKey, NameValueCollection postCollection)
166 posted_file = Page.Request.Files [postDataKey];
171 void RaisePostDataChangedEventInternal ()
173 /* No events to raise */
177 protected virtual bool LoadPostData (string postDataKey, NameValueCollection postCollection)
179 return LoadPostDataInternal (postDataKey, postCollection);
182 protected virtual void RaisePostDataChangedEvent ()
184 RaisePostDataChangedEventInternal ();
188 bool IPostBackDataHandler.LoadPostData (string postDataKey, NameValueCollection postCollection)
191 return LoadPostData (postDataKey, postCollection);
193 return LoadPostDataInternal (postDataKey, postCollection);
197 void IPostBackDataHandler.RaisePostDataChangedEvent ()
200 RaisePostDataChangedEvent ();
202 RaisePostDataChangedEventInternal ();