Anders
Anders

Reputation: 12560

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.

Upvotes: 5

Views: 5823

Answers (1)

tvanfosson
tvanfosson

Reputation: 532465

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.

Upvotes: 6

Related Questions