Groups | Blog | Home
all groups > asp.net building controls > september 2003 >

asp.net building controls : DefaultValue not working (string)



caviar
9/17/2003 12:08:29 PM
My defaultvalue attribute is not working. If i drop this control from
thetoolbox onto my page
the properties are empty. They keep being empty if i run this page on the
server. The only way to fix it is to initialize the property hidden internal
field whit the same value.

Is this by design or is something else wrong?

regards hj

public class WebChangePasswordControl : System.Web.UI.WebControls.WebControl


private string _title; //empty prop everywhere no def value
//private string _title = "Change Password"; //Now the property has an
default value..

[Bindable(false), Category("Appearance"),
DefaultValue("Change Password")]
public string Title
{
get{return _title;}
set{_title = value;}
}

Andrew
9/17/2003 12:28:31 PM
By Design.

The defaultValue attribute is a hint for the designer.
You need to put the same value there that you put into the variable when you
initialize it.

It should change how the design time html for the control is generated.

-Andrew

[quoted text, click to view]

caviar
9/18/2003 9:05:34 AM
[quoted text, click to view]

Ok thanx!

AddThis Social Bookmark Button