Custom Control: DefaultValue attribute doesn't do anything

D

dan

Hi NG,

i am developing an asp.net Custom control which consist of some TextBoxes,
Button, ... .
To let the user of that control set for example the width of the TextBox,
the class has a property like this:

private int widthTextBox;
[Bindable(true),
Category("Appearance"),
DefaultValue(150)] //***
public int WidthTextBox
{
get
{
EnsureChildControls();
return widthTextBox;
}

set
{
EnsureChildControls();
widthTextBox = value;
}
}


The Render(HtmlTextWriter output)assigns this value to the TexBox

protected override void Render(HtmlTextWriter output)
{
UserName.Width=Unit.Pixel(WidthTextBox);
base.Render(output);
}

But the DefaultValue(150) doesn't do anything. When the user doesn't set the
WidthTextBox Property, the TextBox has "Width:0px".
What 's wrong there?

thanks,
Dan
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top