How To: Set Label Text Property In Master Page (From Subscribing Page)?

J

Joey

asp.net 2/C#/VS2005

How do i set the text property for a label control on my master page?
I am able to use...

this.Master.FindControl("lblMyLabel").Visible = false;

....to hide the label. That works fine. However, when trying to set the
text property, I can see there is no "Text" property. So I thought a
cast would work...

((Label)(this.Master.FindControl("lblMyLabel")).Text = "My Text";

....but when I do this nothing happens. No error...just nothing.

What am I doing wrong?

JP
 
M

Mark Rae

((Label)(this.Master.FindControl("lblMyLabel")).Text = "My Text";

That should certainly work...
...but when I do this nothing happens. No error...just nothing.

Are you maybe clearing the property later...?

If you put a breakpoint on the line in question, do you see the value of the
property change...?

Alternatively, do you have more than one MasterPage...?
 
J

Joey

That should certainly work...


Are you maybe clearing the property later...?

If you put a breakpoint on the line in question, do you see the value of the
property change...?

Alternatively, do you have more than one MasterPage...?

--http://www.markrae.net

I did not have the code in the Page_PreRender event handler. After I
moved it there, it worked.
 

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,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top