473,387 Members | 1,742 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Masterpage issue with relative links to background images

I am familiar with the fact that you have to use runat=server and links
staring with "~/" to ensure proper mapping of paths to relative URLs when
using master pages. However this does not seem to work in all cases.

For instance, assume I have a "/mysite/images" subdirectory with
mybackground.gif and mygif.gif in there.

Further assume I have a master page called mastertest.aspx located in
/mysite/myfolder".

In mastertest.aspx this works to produce a proper link to an image:
<img src="~/images/mygif.gif" width="10" height="18" runat=server>

However, this DOES NOT work:
<table width="100" background="~/images/mybackground.gif" runat=server>

For some reason the runat=server works to translate links properly when its
an IMG SRC tag, but not when its a BACKGROUND attribute in a table tag. Why
is this?

What is the work around for this situation? I need to be able to have
ASP.NET dynamically generate the proper relative links to my background
images that are used by my html tables via the BACKGROUND attribute.

Please let me know what I am doing wrong and how I can fix this.

Thanks!

Steve
Nov 19 '05 #1
2 1865
Understanding the 'new but not really new' control and event processing
model [1] is helpful followed up by review of the web application root
operator [2] rules. Check out this forum post [3] regarding usage.

<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/

[1] http://msdn2.microsoft.com/library/d...us,vs.80).aspx
[2] http://msdn2.microsoft.com/library/m...us,vs.80).aspx
[3] http://forums.asp.net/941135/ShowPost.aspx
"Steve Franks" <pl****@postreplyhere.com> wrote in message
news:UM********************@comcast.com...
I am familiar with the fact that you have to use runat=server and links
staring with "~/" to ensure proper mapping of paths to relative URLs when
using master pages. However this does not seem to work in all cases.

For instance, assume I have a "/mysite/images" subdirectory with
mybackground.gif and mygif.gif in there.

Further assume I have a master page called mastertest.aspx located in
/mysite/myfolder".

In mastertest.aspx this works to produce a proper link to an image:
<img src="~/images/mygif.gif" width="10" height="18" runat=server>

However, this DOES NOT work:
<table width="100" background="~/images/mybackground.gif" runat=server>

For some reason the runat=server works to translate links properly when
its an IMG SRC tag, but not when its a BACKGROUND attribute in a table
tag. Why is this?

What is the work around for this situation? I need to be able to have
ASP.NET dynamically generate the proper relative links to my background
images that are used by my html tables via the BACKGROUND attribute.

Please let me know what I am doing wrong and how I can fix this.

Thanks!

Steve

Nov 19 '05 #2
re:
I have a master page called mastertest.aspx
You can't.

You may have a master page called mastertest.master,
not one called mastertest.aspx

Then, you could have any page display the master
page's content by including this line in the aspx page :

<%@ Page Language="VB" MasterPageFile="~/Mastertest.master" %>

You *still* have to use the tilde ( ~ ) as a reference to the
application's root directory, if you want relative paths to work.

See : http://beta.asp.net/QUICKSTART/aspne...s/default.aspx
for a tutorial on how to use master pages.

Juan T. Llibre
ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
===========================

"Steve Franks" <pl****@postreplyhere.com> wrote in message
news:UM********************@comcast.com...I am familiar with the fact that you have to use runat=server and links staring with "~/"
to ensure proper mapping of paths to relative URLs when using master pages. However this
does not seem to work in all cases.

For instance, assume I have a "/mysite/images" subdirectory with mybackground.gif and
mygif.gif in there.

Further assume I have a master page called mastertest.aspx located in /mysite/myfolder".

In mastertest.aspx this works to produce a proper link to an image:
<img src="~/images/mygif.gif" width="10" height="18" runat=server>

However, this DOES NOT work:
<table width="100" background="~/images/mybackground.gif" runat=server>

For some reason the runat=server works to translate links properly when its an IMG SRC
tag, but not when its a BACKGROUND attribute in a table tag. Why is this?

What is the work around for this situation? I need to be able to have ASP.NET
dynamically generate the proper relative links to my background images that are used by
my html tables via the BACKGROUND attribute.

Please let me know what I am doing wrong and how I can fix this.

Thanks!

Steve

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Asad | last post by:
Hi, I am basically trying to accomplish drop down menus for navigation on a site. And I'm pretty much done except I am having one problem. The z-index is not working with relative positioning! ...
2
by: tsteinke | last post by:
Okay here is the situation I am developing a ASP.Net application locally and then I copy the project up to my web server. I start out by creating an ASP.NET Application ...
6
by: Mirek Endys | last post by:
HEEELP!!!! I have a big problem :))))) How to use url in CSS stylesheet file that is linked into MasterPage. The tilda '~' (as shortcut to the root of the webserver) is not working, and my...
7
by: webgyrl | last post by:
Hi, I am helping a musician friend of mine with his profile and I found a cool layout on Nas' MySpace page. I changed some things and re-did the graphics and I basically popped my Image URLS...
2
by: Jerry Qu | last post by:
Hi All, 1) We have masterpage in the root dir 2) if we want ot use materpage for pages in sub dirs, there is probelm to display images called in the masterpage: <table...
0
by: dr1ft3r | last post by:
The background images on this page aren't rendering and it's obviously because of IE's hasLayout issue. If anyone can find the time to pinpoint a solution for me I would be very grateful. Here's the...
1
by: jonathanellis | last post by:
Hello: I am having a problem with a web site that i built not showing up properly in IE6. I haven't tested it in IE7, but I have tested it in Firefox and Safari. Both Firefox and Safari show the...
27
by: GloStix | last post by:
WARNING VIDEO TAKES A WHILE TO LOAD http://screencast.com/t/BWQ6DNtsM I really don't know how to fix this other than putting another div. But I dont' exactly want to do that for every page....
1
by: =?Utf-8?B?bWFya203NQ==?= | last post by:
There is probably some simple answer to my question, but i'm still new to this a bit.. I have a master page.. with a menu system which is coded onto the masterpage.aspx... it uses A tags with...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.