HtmlInputFile.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* System.Web.UI.HtmlControls
  2. * Authors
  3. * Leen Toelen ([email protected])
  4. */
  5. using System;
  6. using System.Web;
  7. using System.Web.UI;
  8. using System.Globalization;
  9. using System.Collections.Specialized;
  10. namespace System.Web.UI.HtmlControls{
  11. public class HtmlInputFile : HtmlInputControl, IPostBackDataHandler{
  12. public HtmlInputFile():base("file"){}
  13. bool IPostBackDataHandler.LoadPostData (string postDataKey,
  14. NameValueCollection postCollection)
  15. {
  16. string postValue = postCollection [postDataKey];
  17. if (postValue != null)
  18. Value = postValue;
  19. return false;
  20. }
  21. void IPostBackDataHandler.RaisePostDataChangedEvent ()
  22. {
  23. }
  24. public string Accept{
  25. get{
  26. string attr = Attributes["accept"];
  27. if (attr != null)
  28. return attr;
  29. return String.Empty;
  30. }
  31. set{
  32. Attributes["accept"] = AttributeToString(value);
  33. }
  34. }
  35. public int MaxLength{
  36. get{
  37. string attr = Attributes["maxlength"];
  38. if (attr != null)
  39. return Int32.Parse(attr, CultureInfo.InvariantCulture);
  40. return -1;
  41. }
  42. set{
  43. Attributes["accept"] = AttributeToString(value);
  44. }
  45. }
  46. public int Size{
  47. get{
  48. string attr = Attributes["size"];
  49. if (attr != null)
  50. return Int32.Parse(attr, CultureInfo.InvariantCulture);
  51. return -1;
  52. }
  53. set{
  54. Attributes["size"] = AttributeToString(value);
  55. }
  56. }
  57. public HttpPostedFile PostedFile{
  58. get{
  59. return Context.Request.Files[RenderedName];
  60. }
  61. }
  62. } // class HtmlInputFile
  63. } // namespace System.Web.UI.HtmlControls