Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to reference control in UC from page?
Message
 
 
To
10/04/2006 09:53:29
Keith Payne
Technical Marketing Solutions
Florida, United States
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01111711
Message ID:
01112084
Views:
19
>>I need to reference an ASP label which is in the User Control, from the code in the page.
>>
>>The page has declaration of the user control, at the top of the pages, as:
>>
>>
>>< %@ Register TagPrefix="uc1" TagName="Header" Src="Header.ascx" % >
>>
>>
>>In the HTML of the page the user control declaration code is:
>>
>>
>><uc1:Header id="Header1" runat="server"></uc1:Header>
>>
>>
>>The user control has ASP label as:
>>
>>
>><asp:Label ID="DbVersion" Runat=server></asp:Label>
>>
>>
>>And I want from the OnLoad method of the page to set value of this label. Pseudo code:
>>
>>uc1.Header1.dbVersion.text = "My Version"
>
>Dmitry,
>
>In the code-behind for the ASCX, declare a public (or protected withfriend) property that directly references the actual control:
>
>
>
>Public Class MyUserControl
>    Inherits System.Web.UI.UserControl
>
>Public ReadOnly Property dbVersion() As System.Web.UI.WebControls.Label
>    Get
>        Return Me.dbVersion
>    End Get
>End Property
>
>...
>

Keith,

First, thank you so much for your help.

How do you convert the code:
Public ReadOnly Property dbVersion As System.Web.UI.WebControls.Label
to C#?
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform