HtmlInputHidden.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 HtmlInputHidden : HtmlInputControl, IPostBackDataHandler{
  12. private static readonly object EventServerChange;
  13. public HtmlInputHidden () : base ("hidden")
  14. {
  15. }
  16. public bool LoadPostData(string postDataKey, NameValueCollection postCollection){
  17. string postValue = postCollection[postDataKey];
  18. if (postValue != null)
  19. Value = postValue;
  20. return false;
  21. }
  22. public virtual void RaisePostDataChangedEvent(){
  23. OnServerChange(EventArgs.Empty);
  24. }
  25. protected void OnServerChange(EventArgs e){
  26. EventHandler handler = (EventHandler) Events[EventServerChange];
  27. if (handler != null) handler.Invoke(this, e);
  28. }
  29. protected override void OnPreRender(EventArgs e){
  30. if (Events[EventServerChange] != null && !Disabled)
  31. ViewState.SetItemDirty("value",false);
  32. }
  33. public event EventHandler ServerChange{
  34. add{
  35. Events.AddHandler(EventServerChange, value);
  36. }
  37. remove{
  38. Events.RemoveHandler(EventServerChange, value);
  39. }
  40. }
  41. } // class HtmlInputFile
  42. } // namespace System.Web.UI.HtmlControls