Programmatically Get to User Control Properties

N

Newbie

I created a User Control, called in an Asp.Net page.

First, I've registered the control at the top of the page:
<%@ Register TagPrefix="uc1" TagName="MyUC" Src="MyUC.ascx" %>

Then, placed the control, as follows:
<uc1:MyUC id="MyUC1" runat="server" TitleText="My custom text"></uc1:MyUC>

The TitleText property is a custom property in the control that alters the text of a label web control inside of the user control, which works fine if I type text directly into the html-source portion of the web page; however, I would like to alter this text dynamically in the code-behind in the Page_Load method, dependent on a variable passed in from another link.

When I try to do something to the effect of either
MyUC1.TitleText = strCustomTextVariable
OR
uc1.TitleText = strCustomTextVariable
I get the following error:
Name MyUC1 is not declared

When I try MyUC.TitleText = strCustomTextVariable, I get
Reference to a non-shared member requires an object reference.

How would I go about doing this? Thanks in advance.
 
A

Andrew Backer

Can you show us what you have in the codebehind?

Do you have a line like this, as with all the other web controls?
protected MyUC MyUC1;
 

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,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top