Creating web controls inside a content placeholder programmatically
I've got a master page and a content page. How can I add controls to the master page's content placehold开发者_JS百科ers programmatically?
Try something like following:
this.Master.Controls.FindControl("ContentPlaceHolderID").Controls.Add(yourControl);
this.Page.Master.FindControl
As said above would work fine.
Alternatively, make whatever placeholder in your master page a ContentPlaceHolder, and then your child pages can put stuff there directly without having to go up through the Master page.
精彩评论