Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Building Controls / June 2006

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jowita - 14 Jun 2006 19:49 GMT
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
Christoph Richter [AT] - 14 Jun 2006 20:56 GMT
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

>I have a simple composite control with the following attributes:
>
[quoted text clipped - 25 lines]
>
>J

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.