New tests.
[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 targetControl)
49                         : this (targetControl, null, null, false, false, false, true, false, null)
50                 {
51                 }
52
53                 public PostBackOptions (Control targetControl, string argument)
54                         : this (targetControl, argument, null, false, false, false, true, false, null)
55                 {
56                 }
57
58                 public PostBackOptions (Control targetControl, string argument, string actionUrl, bool autoPostBack,
59                                         bool requiresJavaScriptProtocol, bool trackFocus, bool clientSubmit,
60                                         bool performValidation, string validationGroup)
61                 {
62                         if (targetControl == null)
63                                 throw new ArgumentNullException ("targetControl");
64                         this.control = targetControl;
65                         this.argument = argument;
66                         this.actionUrl = actionUrl;
67                         this.autoPostBack = autoPostBack;
68                         this.requiresJavaScriptProtocol = requiresJavaScriptProtocol;
69                         this.trackFocus = trackFocus;
70                         this.clientSubmit = clientSubmit;
71                         this.performValidation = performValidation;
72                         this.validationGroup = validationGroup;
73                 }
74
75                 [DefaultValue ("")]
76                 public string ActionUrl {
77                         get { return actionUrl; }
78                         set { actionUrl = value; }
79                 }
80
81                 [DefaultValue ("")]
82                 public string Argument {
83                         get { return  argument; }
84                         set { argument = value; }
85                 }
86
87                 [MonoTODO ("Implement support for this in Page")]
88                 [DefaultValue (false)]
89                 public bool AutoPostBack {
90                         get { return autoPostBack; }
91                         set { autoPostBack = value; }
92                 }
93
94                 [DefaultValue (true)]
95                 public bool ClientSubmit {
96                         get { return clientSubmit; }
97                         set { clientSubmit = value; }
98                 }
99                 
100                 [DefaultValue (false)]
101                 public bool PerformValidation {
102                         get { return performValidation; }
103                         set { performValidation = value; }
104                 }
105
106                 [DefaultValue (true)]
107                 public bool RequiresJavaScriptProtocol {
108                         get { return requiresJavaScriptProtocol; }
109                         set { requiresJavaScriptProtocol = value; }
110                 }
111
112                 [DefaultValue (null)]
113                 public Control TargetControl {
114                         get { return control; }
115                 }
116
117                 [MonoTODO ("Implement support for this in Page")]
118                 [DefaultValue (false)]
119                 public bool TrackFocus {
120                         get { return trackFocus; }
121                         set { trackFocus = value; }
122                 }
123
124                 [MonoTODO ("Implement support for this in Page")]
125                 [DefaultValue ("")]
126                 public string ValidationGroup {
127                         get { return validationGroup; }
128                         set { validationGroup = value; }
129                 }
130                 
131                 // Returns true if some of these options must be handled by
132                 // client script.
133                 internal bool RequiresSpecialPostBack {
134                         get { 
135                                 return actionUrl != null || 
136                                                 validationGroup != null || 
137                                                 trackFocus || 
138                                                 autoPostBack || 
139                                                 argument != null;
140                         }
141                 }
142         }
143 }
144
145 #endif