Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting a property against a control in MasterPage

Status
Not open for further replies.

StevenK

Programmer
Jan 5, 2001
1,294
GB
I have a MasterPageFile set against my web forms in an application.
In certain circumstances I want to set the property of one of the controls - namely the Text against a Literal control (when the user has logged in and the company login is then known).
How can I do this?
So I want to have code in the content panel cause a change in property for one of the MasterPageFile's controls.

Thanks in advance,
Steve
 
expose a public member on the master page. then call the public member from the page.
Code:
public void SetTextTo(string textToDisplay)
{
   MyLiterl.Text = textToDisplay;
}
Code:
// any member you want to set the text with
Master.SetTextTo("foo");
Code:
// any member you want to set the text with
Page.Master.SetTextTo("foo");

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Thank you for that suggestion.
I've put that in practice and can see the code getting stepped through in the master file page - ie. setting the Text property against the Literal control.
However the page itself does not show the Literal control with the desired text. It's almost as if it's being reset again (to it's original property).
Can anyone suggest why this might be?

Steve
 
the page life cycle. depending on when you set the value and how many places you set the value and if the page is a postback or not can all effect the final html output. set a break point on the master page function and step through the code. this will give some insight into the problem.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top