DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Wed, 15 Aug 2007 16:18:17 -0700,    posted on: microsoft.public.dotnet.framework.aspnet        back       

Thread Index
  1    tshad
          2    Ladislav Mrnka


Changing attributes inside a User Control   
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
Date:Wed, 15 Aug 2007 16:18:17 -0700   Author:  

RE: Changing attributes inside a User Control   
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

"tshad" wrote:


> 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
> 
> 
> 
Date:Thu, 16 Aug 2007 17:58:49 -0700   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us