HtmlInputFile.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /* System.Web.UI.HtmlControls
  2. * Authors
  3. * Leen Toelen ([email protected])
  4. */
  5. using System;
  6. using System.ComponentModel;
  7. using System.Web;
  8. using System.Web.UI;
  9. using System.Globalization;
  10. using System.Collections.Specialized;
  11. namespace System.Web.UI.HtmlControls{
  12. [ValidationProperty("Value")]
  13. public class HtmlInputFile : HtmlInputControl, IPostBackDataHandler{
  14. public HtmlInputFile():base("file"){}
  15. bool IPostBackDataHandler.LoadPostData (string postDataKey,
  16. NameValueCollection postCollection)
  17. {
  18. return false;
  19. }
  20. void IPostBackDataHandler.RaisePostDataChangedEvent ()
  21. {
  22. }
  23. [DefaultValue("")]
  24. [WebCategory("Behavior")]
  25. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  26. public string Accept{
  27. get{
  28. string attr = Attributes["accept"];
  29. if (attr != null)
  30. return attr;
  31. return String.Empty;
  32. }
  33. set{
  34. Attributes["accept"] = AttributeToString(value);
  35. }
  36. }
  37. [DefaultValue("")]
  38. [WebCategory("Behavior")]
  39. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  40. public int MaxLength{
  41. get{
  42. string attr = Attributes["maxlength"];
  43. if (attr != null)
  44. return Int32.Parse(attr, CultureInfo.InvariantCulture);
  45. return -1;
  46. }
  47. set{
  48. Attributes["accept"] = AttributeToString(value);
  49. }
  50. }
  51. [DefaultValue("")]
  52. [WebCategory("Appearance")]
  53. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  54. public int Size{
  55. get{
  56. string attr = Attributes["size"];
  57. if (attr != null)
  58. return Int32.Parse(attr, CultureInfo.InvariantCulture);
  59. return -1;
  60. }
  61. set{
  62. Attributes["size"] = AttributeToString(value);
  63. }
  64. }
  65. [DefaultValue("")]
  66. [WebCategory("Misc")]
  67. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  68. public HttpPostedFile PostedFile{
  69. get{
  70. return Context.Request.Files[RenderedName];
  71. }
  72. }
  73. #if NET_1_1
  74. [Browsable (false)]
  75. public override string Value {
  76. get {
  77. HttpPostedFile file = PostedFile;
  78. if (file == null)
  79. return "";
  80. return file.FileName;
  81. }
  82. set {
  83. throw new NotSupportedException ();
  84. }
  85. }
  86. #endif
  87. } // class HtmlInputFile
  88. } // namespace System.Web.UI.HtmlControls