Accessing a code behind variable from ASPX

From: Ryan Taylor (rtaylor_at_stgeorgeconsulting.com)
Date: 11/24/04


Date: Wed, 24 Nov 2004 09:31:09 -0500

Hi.

I need to be able to access a public code behind variable within my ASPX
page. The reason is that I have a user control "Header" which defines a
table layout, and is included in all my pages, at various levels in the
website heirarchy. The table requires a background image. My images folders
is at the root of the website, effectively "~/images/". I need the
background image to show whether I at a page in the root of my website or in
some other directory a few folders down. Normally, I could just write
"~/images/image.jpg" if I was in a code behind file, but I cannot use this
syntax in the ASPX page. So, I have a "VirtualRoot" public variable declared
in my Header.cs file, and this variable is assigned Request.ApplicationPath
on the Page_Load event. This will give me the appropropriate path to prefix
/images/image.jpg. But I cannot remember how to access this variable from
the ASPX page. Any ideas?

Thanks in advance.
Ryan



Relevant Pages

  • Re: Accessing a code behind variable from ASPX
    ... Can you make that public variable a property of the user control, ... > I need to be able to access a public code behind variable within my ASPX ... The table requires a background image. ... > is at the root of the website, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: How to copy protect aspx webpages
    ... with .aspx pages which are dynamically generated on my ... My website is still underconstruction and the ... Secondly when the shopping cart is generated somebody ...
    (microsoft.public.dotnet.languages.vb)
  • NTFS Basic Authentification problem
    ... I have a website that is ... setup for anonymous access. ... However when I move this to a Windows 2000 server with the ... The same ASPX page works fine in an anonymous ...
    (microsoft.public.dotnet.security)
  • Move the App_Code directory
    ... shared between various aspx pages and this works fine. ... pre-existing classic asp 3.0 website. ... is looking in the root of the website rather than my specified aspx ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Visual Studio 2008 SP1 loads website VERY SLOWLY
    ... This project has no explicit assemblies (i.e., it's not a web project, but ... it's a website that compiles when run the 1st time -- all the aspx and vb ... Visual Studio Team System, Development Edition ...
    (microsoft.public.vsnet.general)