views:

360

answers:

3

Hi, I have a page where i in my masterpage have a toolbar with a "Home" button to the far left. This button is not in a contentplaceholder but on the page. I want to have the opportunity for derived pages to add their own controls or whatever to the toolbar to be whown after the "home" button. But how to do this? I have tried to put in a content placeholder, but it seems that i cannot get it to show inline with the other stuff, it breaks and the content of the contentplaceholder is shown below the button instead. anyone know how to solve this?

/Brian

A: 

There are many ways,

  • from derived page you can get to the master page content over Page.MasterPage, and manipulate by controls located there. So you just need to allocate at master server-div or Panel and locate it by Page.MasterPage.FindControl to populate with particular inline elements
  • ContentPlaceholder does nothing with HTML layout, so you header can looks like:

    <div><span> <!-- your Home button declaration goes there --> </span> <span> <asp:ContentPlaceHolder ... </span> </div>

Dewfy
A: 

You can Make the Toolbar in the MasterPage available through a public property. Then you can access the master page from the content using Content.Master propery. Then you can add the controls to the toolbar as you add any runtime control.

Ps : You need to Typecase the Content.Master to the type of your master file class before accessing its public property.

  • Raja
The King
What i forgot to mention is that this is MVC, so i dont have access to the master (at least not that i know of)
H4mm3rHead
A: 

@Comment from Remy in question I started looking and because im crap at designing with CSS (when aligning text and an image vertically center) i made a table that enclosed each button - forgot that table are block elements, so there was my line break. Thx for leading me the right way

/Brian

H4mm3rHead