DefaultValue not working (string)

C

caviar

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;}
}
 
A

Andrew

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
 
C

caviar

Andrew said:
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

Ok thanx!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top