2003-11-18 Todd Berman <tberman@gentoo.org>
[mono.git] / mcs / class / System.Web / System.Web.UI.WebControls / SessionParameter.cs
1 //
2 // System.Web.UI.WebControls.SessionParameter
3 //
4 // Authors:
5 //      Ben Maurer (bmaurer@users.sourceforge.net)
6 //
7 // (C) 2003 Ben Maurer
8 //
9
10 #if NET_1_2
11 using System.Collections;
12 using System.Collections.Specialized;
13 using System.Text;
14
15 namespace System.Web.UI.WebControls {
16         public class SessionParameter : Parameter {
17
18                 public SessionParameter () : base ()
19                 {
20                 }
21
22                 protected SessionParameter (SessionParameter original) : base (original)
23                 {
24                         this.SessionField = original.SessionField;
25                 }
26                 
27                 public SessionParameter (string name, string sessionField) : base (name)
28                 {
29                         SessionField = sessionField;
30                 }
31                 
32                 public SessionParameter (string name, TypeCode type, string sessionField) : base (name, type)
33                 {
34                         SessionField = sessionField;
35                 }
36                 
37                 protected override Parameter Clone ()
38                 {
39                         return new SessionParameter (this);
40                 }
41                 
42                 protected override object Evaluate (Control control)
43                 {
44                         if (control == null || control.Page == null || control.Page.Session == null)
45                                 return null;
46                         
47                         return control.Page.Session [SessionField];
48                 }
49                 
50                 public string SessionField {
51                         get {
52                                 string s = ViewState ["SessionField"] as string;
53                                 if (s != null)
54                                         return s;
55                                 
56                                 return "";
57                         }
58                         set {
59                                 if (SessionField != value) {
60                                         ViewState ["SessionField"] = value;
61                                         OnParameterChanged ();
62                                 }
63                         }
64                 }
65         }
66 }
67 #endif
68