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

  • Thread starter Thread starter Joey
  • Start date Start date
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
 
((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...?
 
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.
 
Back
Top