New test.
[mono.git] / mcs / class / System.Web / System.Web.UI / PostBackOptions.cs
1 //
2 // System.Web.UI.PostBackOptions.cs
3 //
4 // Authors:
5 //      Sanjay Gupta (gsanjay@novell.com)
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
30 #if NET_2_0
31 using System;
32 using System.ComponentModel;
33
34 namespace System.Web.UI
35 {
36         public sealed class PostBackOptions
37         {
38                 private Control control;
39                 private string argument;
40                 private string actionUrl;
41                 private bool autoPostBack;
42                 private bool requiresJavaScriptProtocol;
43                 private bool trackFocus;
44                 private bool clientSubmit;
45                 private bool performValidation;
46                 private string validationGroup;
47                 
48                 public PostBackOptions (Control control) : this (control, null, null, false, true, false, 
49                                                                 true, false, null)
50                 {
51                 }
52
53                 public PostBackOptions (Control control, string argument) : this (control, argument, null, false, 
54                                                                                 true, false, true, false, null)
55                 {
56                 }
57
58                 public PostBackOptions (Control control, string argument, string actionUrl, bool isAutoPostBack,
59                                         bool isJavaScriptProtocolRequired, bool isTrackFocus, bool isClientSubmit,
60                                         bool isValidationPerformed, string validatingGroup)
61                 {
62                         this.control = control;
63                         this.argument = argument == null ? String.Empty : argument;
64                         this.actionUrl = actionUrl == null ? String.Empty : actionUrl;
65                         this.autoPostBack = isAutoPostBack;
66                         this.requiresJavaScriptProtocol = isJavaScriptProtocolRequired;
67                         this.trackFocus = isTrackFocus;
68                         this.clientSubmit = isClientSubmit;
69                         this.performValidation = isValidationPerformed;
70                         this.validationGroup = validatingGroup == null ? String.Empty : validatingGroup;
71                 }
72
73                 [DefaultValue ("")]
74                 public string ActionUrl {
75                         get { return actionUrl; }
76                         set { actionUrl = value; }
77                 }
78
79                 [DefaultValue ("")]
80                 public string Argument {
81                         get { return  argument; }
82                         set { argument = value; }
83                 }
84
85                 [MonoTODO ("Implement support for this in Page")]
86                 [DefaultValue (false)]
87                 public bool AutoPostBack {
88                         get { return autoPostBack; }
89                         set { autoPostBack = value; }
90                 }
91
92                 [DefaultValue (true)]
93                 public bool ClientSubmit {
94                         get { return clientSubmit; }
95                         set { clientSubmit = value; }
96                 }
97                 
98                 [DefaultValue (false)]
99                 public bool PerformValidation {
100                         get { return performValidation; }
101                         set { performValidation = value; }
102                 }
103
104                 [DefaultValue (true)]
105                 public bool RequiresJavaScriptProtocol {
106                         get { return requiresJavaScriptProtocol; }
107                         set { requiresJavaScriptProtocol = value; }
108                 }
109
110                 [DefaultValue (null)]
111                 public Control TargetControl {
112                         get { return control; }
113                 }
114
115                 [MonoTODO ("Implement support for this in Page")]
116                 [DefaultValue (false)]
117                 public bool TrackFocus {
118                         get { return trackFocus; }
119                         set { trackFocus = value; }
120                 }
121
122                 [MonoTODO ("Implement support for this in Page")]
123                 [DefaultValue ("")]
124                 public string ValidationGroup {
125                         get { return validationGroup; }
126                         set { validationGroup = value; }
127                 }
128                 
129                 // Returns true if some of these options must be handled by
130                 // client script.
131                 internal bool RequiresSpecialPostBack {
132                         get { 
133                                 return actionUrl != null || 
134                                                 validationGroup != null || 
135                                                 trackFocus || 
136                                                 autoPostBack || 
137                                                 argument != null;
138                         }
139                 }
140         }
141 }
142
143 #endif