Tuesday, July 20, 2010

Writing Content to ContentPlaceHolder in Code

Add this code to the OnLoad function of the page cs file.

ContentPlaceHolder cph = Master.FindControl("PlaceHolderPageTitleInTitleArea") as ContentPlaceHolder;

if (cph != null)

{

Label lbl = new Label();

lbl.Text = "Hello world";

cph.Controls.Add(lbl);

}

No comments:

Post a Comment