Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > DefaultValue attribute doesn't get set in a composite custom control

Reply
Thread Tools

DefaultValue attribute doesn't get set in a composite custom control

 
 
Jowita
Guest
Posts: n/a
 
      06-14-2006


I have a simple composite control with the following attributes:

[
Bindable(true),
Category("Appearance"),
DefaultValue("Enter name:"),
Description("The text for the name label.")
]
public string NameLabelText
{
get
{
EnsureChildControls();
return nameLabel.Text;
}
set
{
EnsureChildControls();
nameLabel.Text = value;
}
}

However, when I drop the control on the page, the property is NOT set
to the DefaultValue. It is blank.
Can someone help me and explain why the default value doesn't work?

Thanks

J

 
Reply With Quote
 
 
 
 
Christoph Richter [AT]
Guest
Posts: n/a
 
      06-14-2006
That behaviour is per default.

all Standard classes have an if(value == null) implemented to catch
that.
the default value is for the Designer. so if you see the Properties of
your dropped control(normally in the lower right pane), you see there
the default values, that don't need to be set (so you have an code
that is easier to read)

cheers
christoph


On 14 Jun 2006 11:49:01 -0700, "Jowita" <(E-Mail Removed)> wrote:

>
>
>I have a simple composite control with the following attributes:
>
> [
> Bindable(true),
> Category("Appearance"),
> DefaultValue("Enter name:"),
> Description("The text for the name label.")
> ]
> public string NameLabelText
> {
> get
> {
> EnsureChildControls();
> return nameLabel.Text;
> }
> set
> {
> EnsureChildControls();
> nameLabel.Text = value;
> }
> }
>
>However, when I drop the control on the page, the property is NOT set
>to the DefaultValue. It is blank.
>Can someone help me and explain why the default value doesn't work?
>
>Thanks
>
>J


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
When is the System.ComponentModel.DefaultValue attribute applied? Nathan Sokalski ASP .Net 2 01-27-2009 02:46 PM
gridview InsertItemTemplate DefaultValue doesn't get set. paulhux174@hotmail.com ASP .Net 0 01-27-2007 05:13 AM
Custom Control: DefaultValue attribute doesn't do anything dan ASP .Net 0 09-09-2005 08:45 AM
Losing Composite Control property that another Composite Control ... Chad ASP .Net Building Controls 0 02-01-2005 09:01 PM
Possible to create a composite control that has a child control that is a validator that validates the composite control itself? Jonathan Eric Miller ASP .Net Building Controls 2 07-22-2004 10:58 PM



Advertisments