Use UNIX line endings consistently
[mono.git] / mcs / class / System.Web / System.Web.UI.WebControls / Parameter.cs
index 917f0a304c8a371dba032d90dc966100a6473225..b69ec98e75ecf966b020b085945257543390c40b 100644 (file)
@@ -121,11 +121,10 @@ namespace System.Web.UI.WebControls {
                        get { return this.IsTrackingViewState; }
                }
                
+               // MSDN: The ToString method returns the Name property of the Parameter object. If the Parameter object has no name, ToString returns String.Empty.
                public override string ToString ()
                {
-                       object o = GetValue (HttpContext.Current, null);
-                       if (o != null) return o.ToString();
-                       return "";
+                       return Name;
                }
                
                [WebCategoryAttribute ("Parameter")]
@@ -237,32 +236,47 @@ namespace System.Web.UI.WebControls {
                        get { return isTrackingViewState; }
                }
 
+               // MSDN: The default implementation of the Evaluate method is to return 
+               // a null reference (Nothing in Visual Basic) in all cases. 
+               // Classes that derive from the Parameter class override the Evaluate method 
+               // to return an updated parameter value. For example, the ControlParameter object 
+               // returns the value of the control that it is bound to, while 
+               // the QueryStringParameter object retrieves the current name/value pair from 
+               // the HttpRequest object.
                protected virtual object Evaluate (HttpContext context, Control control)
                {
-                       return this.DefaultValue;
+                       return null;
                }
-               
-               internal object GetValue (HttpContext context, Control control)
+
+               internal void UpdateValue (HttpContext context, Control control)
                {
                        object oldValue = ViewState ["ParameterValue"];
-                       
-                       object newValue = ConvertValue (Evaluate (context, control));
-                       if (newValue == null)
-                               newValue = ConvertValue (DefaultValue);
+
+                       object newValue = Evaluate (context, control);
 
                        if (!object.Equals (oldValue, newValue)) {
                                ViewState ["ParameterValue"] = newValue;
                                OnParameterChanged ();
                        }
-                       return newValue;
+               }
+
+               internal object GetValue (HttpContext context, Control control)
+               {
+                       UpdateValue (context, control);
+
+                       object value = ConvertValue (ViewState ["ParameterValue"]);
+                       if (value == null)
+                               value = ConvertValue (DefaultValue);
+
+                       return value;
                }
                
-               object ConvertValue (object val)
+               internal object ConvertValue (object val)
                {
                        if (val == null) return null;
                        if (ConvertEmptyStringToNull && val.Equals (string.Empty))
                                return null;
-                       return Convert.ChangeType (val, Type);
+                       return Type != TypeCode.Empty ? Convert.ChangeType (val, Type) : val;
                }
                
                protected internal virtual void SetDirty()