Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6097301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:01:39+00:00 2026-05-23T13:01:39+00:00

I know you can’t put a control inside a C# function like this <%=

  • 0

I know you can’t put a control inside a C# function like this

<%= VirtualPathUtility.ToAbsolute(<umbraco:Item field="background" runat="server" />) %>

but I am wondering if you can pass the value from a control to a C# function.
umbraco:Item above outputs something like ~/media/bg1.jpg

Here is what I am trying to do:

<%@ 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>

Anyone know any solution? Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:01:40+00:00Added an answer on May 23, 2026 at 1:01 pm

    If it’s just a plain textstring then you can do the following:

    <%@ 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: url('<%=VirtualPathUtility.ToAbsolute(Node.GetCurrent().GetProperty("background").Value)%>');
        }
      </style>
    </asp:content>
    

    However, if the “background” property is a media picker then you need a little more help than just that, which will involve the umbraco.cms.businesslogic.media namespace. I suggest you check out the libraries with Reflector, or the source code repository on Codeplex to find out the classes you should be using and how to subsequently populate your property.

    HTH,

    Benjamin

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to know Can I define any function application wide ? like say
I would like to know can I connect to MySQL from Oracle forms? if
I know can use string.find() to find a substring in a string. But what
i just want to know can we pass nsdata or array datatype from one
I am developing an Image Gallery using scrollview. I want to know can I
I've been slowly writing a little project to create a Movie/TV Show/Music ID3 tag
I need to replace every icon (AutoCAD 2010.LNK) found on the computer with another
Sometimes I'm going nuts over different query execution plans in development, integration tests, and
I'm trying to optimize my WPF/VB.net program, and I'm considering freezing some objects. However,
I am writing a fairly simple extension for Chrome. The main graphical body of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.