Accessing a code behind variable from ASPX

R

Ryan Taylor

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
 
R

Ryan Taylor

Ok. I've managed to solve the problem in another way, I've made the table
server side and added the attribute directly. Though, I would like to know
how to do what I initially asked.
 
B

Ben Strackany

Can you make that public variable a property of the user control, assign the
user control an id, & then access it with <usercontrolid>.<propertyname> ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top