Changing attributes inside a User Control

  • Thread starter Thread starter tshad
  • Start date Start date
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
 
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
 
Back
Top