Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have a field called "background" - for a page background.
In the template I am trying to do this:
<%@ Master Language="C#" MasterPageFile="~/masterpages/Master.master" AutoEventWireup="true" %><asp:content ContentPlaceHolderId="cphHead" runat="server"> <style type="text/css"> #content { background: url('<%=VirtualPathUtility.ToAbsolute(<umbraco:Item field="background" runat="server" />)%>'); } </style></asp:content>
But it doesn't like it. Anyone know how do to this?
Hi Hardi
The background property is this a upload field?
Could you try this snippet:
<%@MasterLanguage="C#"MasterPageFile="/masterpages/Master.master"AutoEventWireup="true" %><asp:content ContentPlaceHolderId="cphHead"runat="server"> <styletype="text/css"> #content { background: url(<umbraco:Item field="background" runat="server" />); } </style></asp:content>
/Kim A
Yes, thanks Kim, sorry forgot to mention it is an Upload field.
Your code produces this
background: url(~/media/15/about-cooper-street.jpg);
How do I fix the tilde ~ ? Thanks!
Here is the solution
<%@ Master Language="C#" MasterPageFile="~/masterpages/Master.master" AutoEventWireup="true" %><%@ Import Namespace="umbraco" %><%@ Import Namespace="umbraco.presentation" %><%@ Import Namespace="umbraco.presentation.nodeFactory" %><asp:content ContentPlaceHolderId="cphHead" runat="server"> <style type="text/css"> #content { background-image: url('<%=VirtualPathUtility.ToAbsolute(Node.GetCurrent().GetProperty("background").Value)%>'); } </style></asp:content>
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
How do you output a field in head > style
I have a field called "background" - for a page background.
In the template I am trying to do this:
But it doesn't like it. Anyone know how do to this?
Hi Hardi
The background property is this a upload field?
Could you try this snippet:
/Kim A
Yes, thanks Kim, sorry forgot to mention it is an Upload field.
Your code produces this
How do I fix the tilde ~ ? Thanks!
Here is the solution
is working on a reply...