HtmlInputButton.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* System.Web.UI.HtmlControls
  2. * Authors
  3. * Leen Toelen ([email protected])
  4. */
  5. using System;
  6. using System.ComponentModel;
  7. using System.Globalization;
  8. using System.Web;
  9. using System.Web.UI;
  10. namespace System.Web.UI.HtmlControls{
  11. [DefaultEvent("ServerClick")]
  12. public class HtmlInputButton : HtmlInputControl, IPostBackEventHandler{
  13. private static readonly object EventServerClick;
  14. public HtmlInputButton(): base ("button")
  15. {
  16. }
  17. public HtmlInputButton(string type): base(type){}
  18. protected override void OnPreRender (EventArgs e)
  19. {
  20. base.OnPreRender(e);
  21. }
  22. protected override void RenderAttributes (HtmlTextWriter writer)
  23. {
  24. base.RenderAttributes (writer);
  25. }
  26. protected virtual void OnServerClick(EventArgs e){
  27. EventHandler handler = (EventHandler) Events[EventServerClick];
  28. if (handler != null){
  29. handler.Invoke(this, e);
  30. }
  31. }
  32. void IPostBackEventHandler.RaisePostBackEvent (string eventArgument)
  33. {
  34. if(CausesValidation == true){
  35. Page.Validate();
  36. }
  37. OnServerClick(EventArgs.Empty);
  38. }
  39. public event EventHandler ServerClick{
  40. add{
  41. Events.AddHandler(EventServerClick, value);
  42. }
  43. remove{
  44. Events.RemoveHandler(EventServerClick, value);
  45. }
  46. }
  47. public bool CausesValidation{
  48. get{
  49. object causesVal = ViewState["CausesValidation"];
  50. if (causesVal != null){
  51. return (Boolean) causesVal;
  52. }
  53. return true;
  54. }
  55. set{
  56. ViewState["CausesValidation"] = (Boolean) value;
  57. }
  58. }
  59. } // end of System.Web.UI.HtmlControls.HtmlInputButton
  60. } // namespace System.Web.UI.HtmlControls