// Author:
// Dick Porter <dick@ximian.com>
//
-// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2005-2010 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
[ValidationProperty ("Value")]
public class HtmlInputFile : HtmlInputControl , IPostBackDataHandler
{
+ HttpPostedFile posted_file;
+
public HtmlInputFile () : base ("file")
{
}
[DefaultValue ("")]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[WebSysDescription("")]
- public string Accept
- {
+ public string Accept {
get {
string acc = Attributes["accept"];
[DefaultValue ("")]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[WebSysDescription("")]
- public int MaxLength
- {
+ public int MaxLength {
get {
string maxlen = Attributes["maxlength"];
}
}
}
-
- HttpPostedFile posted_file;
[DefaultValue ("")]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[WebSysDescription("")]
[WebCategory("Misc")]
- public HttpPostedFile PostedFile
- {
+ public HttpPostedFile PostedFile {
get {
return (posted_file);
}
}
-#if NET_2_0
[DefaultValue ("-1")]
-#else
- [DefaultValue ("")]
-#endif
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[WebSysDescription("")]
[WebCategory("Appearance")]
- public int Size
- {
+ public int Size {
get {
string size = Attributes["size"];
}
[Browsable (false)]
- public override string Value
- {
+ public override string Value {
get {
- string value = Attributes["value"];
+ HttpPostedFile file = PostedFile;
+ if (file == null)
+ return string.Empty;
- if (value == null) {
- return (String.Empty);
- }
-
- return (value);
+ return file.FileName;
}
set {
throw new NotSupportedException ("The value property on HtmlInputFile is not settable.");
}
}
-#if NET_2_0
- protected internal
-#else
- protected
-#endif
- override void OnPreRender (EventArgs e)
+ protected internal override void OnPreRender (EventArgs e)
{
base.OnPreRender (e);
- if (Page != null) {
- Page.RegisterRequiresPostBack (this);
+ Page page = Page;
+ if (page != null && !Disabled) {
+ page.RegisterRequiresPostBack (this);
+ page.RegisterEnabledControl (this);
}
-
+
HtmlForm form = (HtmlForm) SearchParentByType (typeof (HtmlForm));
- if (form != null && form.Enctype == "")
+ if (form != null && form.Enctype == String.Empty)
form.Enctype = "multipart/form-data";
}
bool LoadPostDataInternal (string postDataKey, NameValueCollection postCollection)
{
- posted_file = Page.Request.Files [postDataKey];
+ Page page = Page;
+ if (page != null)
+ posted_file = page.Request.Files [postDataKey];
return (false);
}
/* No events to raise */
}
-#if NET_2_0
protected virtual bool LoadPostData (string postDataKey, NameValueCollection postCollection)
{
return LoadPostDataInternal (postDataKey, postCollection);
{
RaisePostDataChangedEventInternal ();
}
-#endif
bool IPostBackDataHandler.LoadPostData (string postDataKey, NameValueCollection postCollection)
{
-#if NET_2_0
return LoadPostData (postDataKey, postCollection);
-#else
- return LoadPostDataInternal (postDataKey, postCollection);
-#endif
}
void IPostBackDataHandler.RaisePostDataChangedEvent ()
{
-#if NET_2_0
RaisePostDataChangedEvent ();
-#else
- RaisePostDataChangedEventInternal ();
-#endif
}
}
}