HtmlInputHidden.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* System.Web.UI.HtmlControls
  2. * Authors
  3. * Leen Toelen ([email protected])
  4. */
  5. using System;
  6. using System.Collections.Specialized;
  7. using System.ComponentModel;
  8. using System.Globalization;
  9. using System.Web;
  10. using System.Web.UI;
  11. namespace System.Web.UI.HtmlControls{
  12. [DefaultEvent("ServerChange")]
  13. public class HtmlInputHidden : HtmlInputControl, IPostBackDataHandler{
  14. private static readonly object EventServerChange = new object ();
  15. public HtmlInputHidden () : base ("hidden")
  16. {
  17. }
  18. bool IPostBackDataHandler.LoadPostData (string postDataKey,
  19. NameValueCollection postCollection)
  20. {
  21. string postValue = postCollection [postDataKey];
  22. if (postValue != null)
  23. Value = postValue;
  24. return false;
  25. }
  26. void IPostBackDataHandler.RaisePostDataChangedEvent ()
  27. {
  28. // don't need anything. LoadPostData always returns false.
  29. }
  30. protected virtual void OnServerChange (EventArgs e)
  31. {
  32. EventHandler handler = (EventHandler) Events [EventServerChange];
  33. if (handler != null) handler.Invoke (this, e);
  34. }
  35. protected override void OnPreRender(EventArgs e){
  36. if (Events[EventServerChange] != null && !Disabled)
  37. ViewState.SetItemDirty("value",false);
  38. }
  39. [WebCategory("Action")]
  40. [WebSysDescription("Fires when the value of the control changes.")]
  41. public event EventHandler ServerChange{
  42. add{
  43. Events.AddHandler(EventServerChange, value);
  44. }
  45. remove{
  46. Events.RemoveHandler(EventServerChange, value);
  47. }
  48. }
  49. } // class HtmlInputFile
  50. } // namespace System.Web.UI.HtmlControls