Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set ContentPlaceHolder data through code ASP.NET

Is it possible to set the data in a ContentPlaceHolder through code? This is what I am thinking of:

dim oCPH as new ContentPlaceHolder
oCPH.id = "column1" 'this id is the one that corresponds with the ID I set on the page
oCPH.content = "content here" '<-- not real code

Obviously that is not correct syntax, I hope that this clarifies what I am asking.

like image 997
Anders Avatar asked Oct 10 '08 21:10

Anders


1 Answers

You should be able to reference it through the MasterPage element on the current page. Something like:

ContentPlaceHolder cph = (ContentPlaceHolder)Master.FindControl("column1");

If in the MasterPage codebehind, just reference it by name.

like image 96
tvanfosson Avatar answered Sep 27 '22 16:09

tvanfosson