HtmlInputFile.cs 1.5 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. public bool LoadPostData(string postDataKey, NameValueCollection postCollection){
  14. string postValue = postCollection[postDataKey];
  15. if (postValue != null){
  16. Value = postValue;
  17. }
  18. return false;
  19. }
  20. public void RaisePostDataChangedEvent(){}
  21. public string Accept{
  22. get{
  23. string attr = Attributes["accept"];
  24. if (attr != null){
  25. return attr;
  26. }
  27. return "";
  28. }
  29. set{
  30. Attributes["accept"] = MapStringAttributeToString(value);
  31. }
  32. }
  33. public int MaxLength{
  34. get{
  35. string attr = Attributes["maxlength"];
  36. if (attr != null){
  37. return Int32.Parse(attr, CultureInfo.InvariantCulture);
  38. }
  39. return -1;
  40. }
  41. set{
  42. Attributes["accept"] = MapIntegerAttributeToString(value);
  43. }
  44. }
  45. public int Size{
  46. get{
  47. string attr = Attributes["size"];
  48. if (attr != null){
  49. return Int32.Parse(attr);
  50. }
  51. return -1;
  52. }
  53. set{
  54. Attributes["size"] = MapIntegerAttributeToString(value);
  55. }
  56. }
  57. public HttpPostedFile PostedFile{
  58. get{
  59. return Context.Request.Files[RenderedNameAttribute];
  60. }
  61. }
  62. } // class HtmlInputFile
  63. } // namespace System.Web.UI.HtmlControls