2
0

HtmlInputButton.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. namespace System.Web.UI.HtmlControls{
  10. public class HtmlInputButton : HtmlInputControl, IPostBackEventHandler{
  11. private static readonly object EventServerClick;
  12. public HtmlInputButton(): base ("button")
  13. {
  14. }
  15. public HtmlInputButton(string type): base(type){}
  16. protected void OnServerClick(EventArgs e){
  17. EventHandler handler = (EventHandler) Events[EventServerClick];
  18. if (handler != null){
  19. handler.Invoke(this, e);
  20. }
  21. }
  22. public void RaisePostBackEvent(string eventArgument){
  23. if(CausesValidation == true){
  24. Page.Validate();
  25. }
  26. OnServerClick(EventArgs.Empty);
  27. }
  28. public event EventHandler ServerClick{
  29. add{
  30. Events.AddHandler(EventServerClick, value);
  31. }
  32. remove{
  33. Events.RemoveHandler(EventServerClick, value);
  34. }
  35. }
  36. public bool CausesValidation{
  37. get{
  38. object causesVal = ViewState["CausesValidation"];
  39. if (causesVal != null){
  40. return (Boolean) causesVal;
  41. }
  42. return true;
  43. }
  44. set{
  45. ViewState["CausesValidation"] = (Boolean) value;
  46. }
  47. }
  48. } // end of System.Web.UI.HtmlControls.HtmlInputButton
  49. } // namespace System.Web.UI.HtmlControls