Changing attributes inside a User Control

T

tshad

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
 
G

Guest

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
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top