I have a site where I use masterpages and childs. On the masterpage I have a <div> containing a background image in which I would like to change when moving to the childpages.
I think you can access controls from the master page using the Master property of a page: Master.FindControl("someId"). So you can add runat="server" to the div and try to find it from the child page. You can have a .net macro in the child page that does this.
I use a variation of what bfi suggested. You can put a public property on your master that you use for the class. Then in the child create an instance of the master and you can set the value of the public property. Something like this:
MyMasterPage mmp = Page.Master.Master as MyMasterPage;
mmp.PublicProperty = "whateverClassForTheChild";
We often add a ContentPlaceHolder in the parent template located in the <head> tags. Then in the child templates we'll add javascript specific for the internal pages. In the example below the Parent template would include a reference to jQuery and have a ContentPlaceHolder below the reference also in the <head> tag. Then in the child templates we add the content area that is associated with the ContentPlaceholder on the parent template. Now we just add the jQuery below to swap out a background image.
Change Masterpage <div> from childpage?
Hi All,
I'm new to Umbraco so please bare with me.
I have a site where I use masterpages and childs. On the masterpage I have a <div> containing a background image in which I would like to change when moving to the childpages.
How can this be done?
Snippet from master.template:
CSS:
Thanks in advanced!
Rgds
Brian
Hi Brian,
I tend to create a number of classes on the body tag as follows:
Basically this creates 3 classes
1) txxxx - 't' + the template id
2) dtxxxx - 'dt' + the doc type id
3) pxxxx - 'p' + the page id
Then you could just create a class per template/doctype/page
This method assumes the images are hard coded. Let me know if that's not the case.
Matt
I think you can access controls from the master page using the Master property of a page: Master.FindControl("someId"). So you can add runat="server" to the div and try to find it from the child page. You can have a .net macro in the child page that does this.
Hope this helps!
I use a variation of what bfi suggested. You can put a public property on your master that you use for the class. Then in the child create an instance of the master and you can set the value of the public property. Something like this:
We often add a ContentPlaceHolder in the parent template located in the <head> tags. Then in the child templates we'll add javascript specific for the internal pages. In the example below the Parent template would include a reference to jQuery and have a ContentPlaceHolder below the reference also in the <head> tag. Then in the child templates we add the content area that is associated with the ContentPlaceholder on the parent template. Now we just add the jQuery below to swap out a background image.
<script type="text/javascript">
$(document).ready(function () {
$('#mainContent').css("background-image", "url(/media/internalpagebackground.jpg)");
});
</script>
Good luck
Eric
Woaoh - thanks for all the great answers!
/Brian
is working on a reply...