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 / General / August 2007

Tip: Looking for answers? Try searching our database.

Changing attributes inside a User Control

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
tshad - 16 Aug 2007 00:18 GMT
I have a User control that has some asp:textboxes and asp:labels in it where
I want to change the visibility and forecolor of these controls.

Right now I am getting and setting the .net controls using properties:
***************************************
Public Property FullName AS String
 Get
  Return objFullName.Text
 End Get
 Set
  objFullName.Text = Value
 End Set
End Property

Public Property Address1 AS String
 Get
  Return objAddress1.Text
 End Get
 Set
  objAddress1.Text = Value
 End Set
End Property

Public Property City AS String
 Get
  Return objContactCity.Text
 End Get
 Set
  objCity.Text = Value
 End Set
End Property

***************************************

But I can't use these properties to change other attributes.  I could set up
other properties to do this but that would require setting up a lot of
properties something like:
*****************************************************
       Public Property FullNameColor As Color
           Get
               Return FullName.ForeColor
           End Get
           Set
               lblMessage.ForeColor = value
           End Set
       End Property
*****************************************************

Is this the best way to handle this?

Thanks,

Tom
Ladislav Mrnka - 17 Aug 2007 01:58 GMT
Hi Tom,
yes you have to create public properties to access your control's
attributes. If you need to change a lot of settings for each child control
you can think about creating public properties which will return reference to
these controls or definitely leave ASP.NET 2.0 code behind model and swap to
ASP.NET 1.1 model where you have to declare controls in code behind find at
your own and you can choose if they will be protected or public.

Regards,
Ladislav

> I have a User control that has some asp:textboxes and asp:labels in it where
> I want to change the visibility and forecolor of these controls.
[quoted text clipped - 49 lines]
>
> Tom

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



©2008 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.