Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeUsing DNN Platf...Using DNN Platf...Skins, Themes, ...Skins, Themes, ...Background Image per Page ?Background Image per Page ?
Previous
 
Next
New Post
2/2/2010 1:36 AM
 

Hi all,

I need to set the Page Background Image for each Page.

I found a Blog entry by John Mitchell (here) but I have some Problems...

I changed the Body Tag in my Default.aspx like this:

<body id="Body" style="background-image:url( <%= SkinPath & PortalSettings.ActiveTab.TabName %> BG.jpg );background-repeat:no-repeat;" runat="server" >

But the rendered Result looks like that :

<body id="Body" style="background-image:url( &lt;%= SkinPath &amp; PortalSettings.ActiveTab.TabName %> BG.jpg );background-repeat:no-repeat;">
The first <%= is rendered Like a normal character...
 
Whats wrong in my Code ?
Any help is welcome !

Kind Regards
Peter


 

 

 
New Post
2/11/2010 8:16 AM
 

Not sure what your doing wrong there.  AN alternative if you cant find the answer is the following (not sure if this is recommended by others, probably a bit fo a hack)

Create a control and add it somewhere in your skin.  Then create a Literal and in the code set the literals text on load to some css.

ie

protected void Page_Load(object sender, EventArgs e){

myLiteral.Text = @"

<style type='text/css'>

#Body { background-image:url('" + SkinPath + PortalSettings.ActiveTab.TabName + @"BG.jpg');

</style>";

}

Might not be SkinPath, might be Skin.GetSkin(Page).SkinPath.  Not sure, you'll have to have a play around and see what works.  I use this method to dynamically change the css when users click on resize buttons and for inserting browser specific css for... well...you know ie6.

Off the top of my head maybe try using single quotes instead for your original problem.

 
New Post
2/12/2010 5:55 AM
 

Peter,

There is a much easier option, where you can add css to the Page Header Tags option in the page settings for each individial page.

Any code you insert in the Meta Header Tags appears below all CSS files so you can override any default background image by using the following code.

<style type="text/css">
body#Body{
background-image:url(images/image.gif);
}
</style>

This way you can set a default background image for the skin, and override this on a per page basis.

Hope this helps.

Rick.



PSDtoDNN - You supply the artwork... we'll build the skins!™
Website | Twitter | YouTube | Skype
 
New Post
2/12/2010 6:40 AM
 

I would not edit default.aspx, that's a core hack.
That will result in problems in the future with upgrades, portability etc.
(you are setting design features of the skin outside the skin)

IMO you should always make these kind of changes from the skin, so make sure you are installtion independent.

There are two ways to do this.

1. Use a (wrapping) div in your skin and set the BG for that div using the technique you posted.
(You need to set height for body, form and this div to 100%)

2. Use code to change the body tag.
Using something like Me.Page.FindControl("Body") in the skins page_load
 

 
New Post
2/12/2010 7:03 AM
 

Hi Peter,

Unfortunately you can't use inline code like that in a server control (runat="server"). There would be two alternative ways to get the effect you're after. First, you can get an inline style like this:

<script language="vb" runat=server>
Protected Overrides Sub OnLoad(ByVal e As EventArgs)
MyBase.OnLoad(e)
CType(Page.FindControl("Body"), HtmlGenericControl).Attributes("style") = "background-image:url(" & SkinPath & PortalSettings.ActiveTab.TabName & ")"
End Sub
</script>

Alternatively, you can put it in a style block:

<style type="text/css">
#Body {
background-image: url(<%= SkinPath & PortalSettings.ActiveTab.TabName %>BG.jpg);
}
</style>

Depending on your setup, you could also consider using the first method to set a class rather than a style, which would give you a bit more control if you might be using the same image on more than one page. I would tend to advise against Rick's suggestion, as I've worked on sites that did it that way before and it's a bit of a nightmare to maintain.

 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Skins, Themes, ...Skins, Themes, ...Background Image per Page ?Background Image per Page ?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out