HtmlInputFile.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. string postValue = postCollection [postDataKey];
  19. if (postValue != null)
  20. Value = postValue;
  21. return false;
  22. }
  23. void IPostBackDataHandler.RaisePostDataChangedEvent ()
  24. {
  25. }
  26. [DefaultValue("")]
  27. [WebCategory("Behavior")]
  28. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  29. public string Accept{
  30. get{
  31. string attr = Attributes["accept"];
  32. if (attr != null)
  33. return attr;
  34. return String.Empty;
  35. }
  36. set{
  37. Attributes["accept"] = AttributeToString(value);
  38. }
  39. }
  40. [DefaultValue("")]
  41. [WebCategory("Behavior")]
  42. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  43. public int MaxLength{
  44. get{
  45. string attr = Attributes["maxlength"];
  46. if (attr != null)
  47. return Int32.Parse(attr, CultureInfo.InvariantCulture);
  48. return -1;
  49. }
  50. set{
  51. Attributes["accept"] = AttributeToString(value);
  52. }
  53. }
  54. [DefaultValue("")]
  55. [WebCategory("Appearance")]
  56. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  57. public int Size{
  58. get{
  59. string attr = Attributes["size"];
  60. if (attr != null)
  61. return Int32.Parse(attr, CultureInfo.InvariantCulture);
  62. return -1;
  63. }
  64. set{
  65. Attributes["size"] = AttributeToString(value);
  66. }
  67. }
  68. [DefaultValue("")]
  69. [WebCategory("Misc")]
  70. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  71. public HttpPostedFile PostedFile{
  72. get{
  73. return Context.Request.Files[RenderedName];
  74. }
  75. }
  76. } // class HtmlInputFile
  77. } // namespace System.Web.UI.HtmlControls