Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Building Controls (http://www.velocityreviews.com/forums/f59-asp-net-building-controls.html)
-   -   Programmatically Get to User Control Properties (http://www.velocityreviews.com/forums/t757816-programmatically-get-to-user-control-properties.html)

Newbie 07-13-2005 09:58 PM

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.

Andrew Backer 07-14-2005 12:29 AM

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;


Newbie 07-14-2005 12:55 PM

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.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57