2003-11-17 Ben Maurer <bmaurer@users.sourceforge.net>
[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                 protected SessionParameter (SessionParameter original) : base (original)
18                 {
19                         this.SessionField = original.SessionField;
20                 }
21                 
22                 public SessionParameter (string name, string sessionField) : base (name)
23                 {
24                         SessionField = sessionField;
25                 }
26                 
27                 public SessionParameter (string name, TypeCode type, string sessionField) : base (name, type)
28                 {
29                         SessionField = sessionField;
30                 }
31                 
32                 protected override Parameter Clone ()
33                 {
34                         return new SessionParameter (this);
35                 }
36                 
37                 protected override object Evaluate (Control control)
38                 {
39                         if (control == null || control.Page == null || control.Page.Session == null)
40                                 return null;
41                         
42                         return control.Page.Session [SessionField];
43                 }
44                 
45                 public string SessionField {
46                         get {
47                                 string s = ViewState ["SessionField"] as string;
48                                 if (s != null)
49                                         return s;
50                                 
51                                 return "";
52                         }
53                         set {
54                                 if (SessionField != value) {
55                                         ViewState ["SessionField"] = value;
56                                         OnParameterChanged ();
57                                 }
58                         }
59                 }
60         }
61 }
62 #endif
63