Site structure
Version 4.x > Site structure > Changing Body ID dynamically. View modes: 
User avatar
Member
Member
john-squareroot-inc - 9/2/2009 2:56:29 PM
   
Changing Body ID dynamically.
Hello,

I am using the portal engine method of development, and I need to change a <body id=""> tag of the master page for a some content. I have not discovered a way to do this.

I'd really rather not create a .aspx template for this. Please help?

User avatar
Kentico Support
Kentico Support
kentico_radekm - 9/4/2009 4:54:04 AM
   
RE:Changing Body ID dynamically.
Hello.

I am not quite sure what ID do you mean. You mean class parameter? If you are using Portal engine, then <solution>/CMSPages/PortalTemplate.aspx is used as master page and you can dynamically change its properties in its code-behind, e.g. in OnPreInit method. E.g. if you want to change class parameter, you can change "this.BodyClass =" parameter. You can change it e.g. on dependance on current node´s alias path using this condition

if (CMS.CMSHelper.CMSContext.CurrentDocument.NodeAlias == "someNodeAlias")
{
this.BodyClass = "something";
}
else
{
this.BodyClass = "somethingElse";
}

If you want to achieve something else, could you please clarify it? Thank you.

Best Regards,
Radek Macalik