![]() |
Programmatically Get to User Control Properties
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. |
Re: Programmatically Get to User Control Properties
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; |
Re: Programmatically Get to User Control Properties
Thanks. I was missing that line, which fixed the problem.
"Andrew Backer" <awbacker@gmail.com> wrote in message news:1121300949.847313.8840@g49g2000cwa.googlegrou ps.com... > 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; > |
| All times are GMT. The time now is 03:00 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.