Re-using asp:label

F

footballhead

I do some design work on a website that up until to now has been
limited to defining CSS and HTML elements. Excuse me if I am using
incorrect terminology, I am just starting out in this.

I would like to try some beginning coding and the developers are giving
me some latitude to experiment. They said that I can use INLINE VB
code.

I would like to create an ASCX file that uses some labels that are on
the parent page that that ascx file will be called from. The labels I
want to use are-

<asp:Label ID="lblQuery" Visible="False" Runat="server"></asp:Label>

<asp:Label ID="lblCategory" Visible="False" Runat="server"></asp:Label>

Can any of you lend a hand or point me to a tutorial that specifically
addresses this type of thing?

Thanks much,

RD
 
G

Gerhard Pretorius

You will have to create public properties on the UserControl (ASP.NET 2.0)
and manage them from the container page.
(This is a great new feature in ASP.NET 2.0) After dropping the control on a
page, the public properties are immediately available. (No need to load
control and cast it as in ASP.NET 1.1)

In the property set the label fields text directly: eg: In the ascx
public string Query
{
set { lblQuery.Text = value; }
get { return lblQuery.Text; }
}

Gerhard
 

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

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,278
Latest member
BuzzDefenderpro

Latest Threads

Top