PostBackOptions.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. //
  2. // System.Web.UI.PostBackOptions.cs
  3. //
  4. // Authors:
  5. // Sanjay Gupta ([email protected])
  6. //
  7. // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
  8. //
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. #if NET_2_0
  30. using System;
  31. using System.ComponentModel;
  32. namespace System.Web.UI
  33. {
  34. public sealed class PostBackOptions
  35. {
  36. private Control control;
  37. private string argument;
  38. private string actionUrl;
  39. private bool autoPostBack;
  40. private bool requiresJavaScriptProtocol;
  41. private bool trackFocus;
  42. private bool clientSubmit;
  43. private bool performValidation;
  44. private string validationGroup;
  45. public PostBackOptions (Control control) : this (control, null, null, false, false, false,
  46. false, false, null)
  47. {
  48. }
  49. public PostBackOptions (Control control, string argument) : this (control, argument, null, false,
  50. false, false, false, false, null)
  51. {
  52. }
  53. public PostBackOptions (Control control, string argument, string actionUrl, bool isAutoPostBack,
  54. bool isJavaScriptProtocolRequired, bool isTrackFocus, bool isClientSubmit,
  55. bool isValidationPerformed, string validatingGroup)
  56. {
  57. this.control = control;
  58. this.argument = argument;
  59. this.actionUrl = actionUrl;
  60. this.autoPostBack = isAutoPostBack;
  61. this.requiresJavaScriptProtocol = isJavaScriptProtocolRequired;
  62. this.trackFocus = isTrackFocus;
  63. this.clientSubmit = isClientSubmit;
  64. this.performValidation = isValidationPerformed;
  65. this.validationGroup = validatingGroup;
  66. }
  67. [DefaultValue ("")]
  68. public string ActionUrl {
  69. get { return actionUrl; }
  70. set { actionUrl = value; }
  71. }
  72. [DefaultValue ("")]
  73. public string Argument {
  74. get { return argument; }
  75. set { argument = value; }
  76. }
  77. [MonoTODO ("Implement support for this in Page")]
  78. [DefaultValue (false)]
  79. public bool AutoPostBack {
  80. get { return autoPostBack; }
  81. set { autoPostBack = value; }
  82. }
  83. [DefaultValue (true)]
  84. public bool ClientSubmit {
  85. get { return clientSubmit; }
  86. set { clientSubmit = value; }
  87. }
  88. [DefaultValue (false)]
  89. public bool PerformValidation {
  90. get { return performValidation; }
  91. set { performValidation = value; }
  92. }
  93. [DefaultValue (true)]
  94. public bool RequiresJavaScriptProtocol {
  95. get { return requiresJavaScriptProtocol; }
  96. set { requiresJavaScriptProtocol = value; }
  97. }
  98. [DefaultValue (null)]
  99. public Control TargetControl {
  100. get { return control; }
  101. }
  102. [MonoTODO ("Implement support for this in Page")]
  103. [DefaultValue (false)]
  104. public bool TrackFocus {
  105. get { return trackFocus; }
  106. set { trackFocus = value; }
  107. }
  108. [MonoTODO ("Implement support for this in Page")]
  109. [DefaultValue ("")]
  110. public string ValidationGroup {
  111. get { return validationGroup; }
  112. set { validationGroup = value; }
  113. }
  114. // Returns true if some of these options must be handled by
  115. // client script.
  116. internal bool RequiresSpecialPostBack {
  117. get {
  118. return actionUrl != null ||
  119. validationGroup != null ||
  120. trackFocus ||
  121. autoPostBack ||
  122. argument != null;
  123. }
  124. }
  125. }
  126. }
  127. #endif