Re: Accessing a code behind variable from ASPX

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Jeff Dillon (jeff_at_removeemergencyreporting.com)
Date: 11/24/04


Date: Wed, 24 Nov 2004 08:58:51 -0800

What is your variable name, and what datatype did you declare it to be?

Jeff

"Ryan Taylor" <rtaylor@stgeorgeconsulting.com> wrote in message
news:O3Qt#Ij0EHA.424@TK2MSFTNGP14.phx.gbl...
> 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: I have a question about declaring the Global.ascx:
    ... are put under 4 folders, but web pages would be called across the 4 ... web page Page1 in Project1 will redirect to web ... In each web page, some session variables, such as customer ID, Product ... so I declare these variables in Global.ascx. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: basic ?: sharing variables between functions/subs
    ... > best to declare your variables with the narrowest scope possible. ... It's an image upload and resize tool. ... namely some different paths to different folders. ... I did some digging and what I finally did was just declare these ...
    (microsoft.public.dotnet.framework.aspnet)
  • I have a question about declaring the Global.ascx:
    ... are put under 4 folders, but web pages would be called across the 4 ... web page Page1 in Project1 will redirect to web ... so I declare these variables in Global.ascx. ... Tarun sinha ...
    (microsoft.public.dotnet.languages.csharp)