473,405 Members | 2,344 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,405 software developers and data experts.

sharing master page question

I have 1 master page in the root of my website that I would like to share
with all pages, even those in my /admin and /client directories. But when
pages in the subdir's are viewed the img, css, etc... references are
incorrect because they are "root based". Any suggestion as to how to
overcome this? Or do I have to create another Master Page for the subdir
pages?

Thansk!
Jun 27 '08 #1
8 1267
You are obviously using relative URLs in your code, which is good, but when
files in different directories are involved in the same page, it is good to
make sure they will all work for that page (and all pages they are used in).
Here are a few ideas that may help:

1. For directories that are used by almost all pages (and Master pages and
UserControls), such as an /images/ directory for example, it is good to
write it as /images/ rather than images/ so that it is relative to the root
instead of the current directory. This will save you the trouble of needing
to worry about whether to use the directory of the Page, Master Page,
UserControl, CSS file, JavaScript file, etc.

2. For any server controls, you can use ~/path/ The ~ represents the root of
the site. For more details on this, see the documentation.

Even though this may sometimes make your URLs longer than is always
absolutely necessary, it can usually save you a lot of trouble and make it
easier to modify code later in development. Hopefully some of this helps.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Cirene" <ci****@nowhere.comwrote in message
news:ud**************@TK2MSFTNGP02.phx.gbl...
>I have 1 master page in the root of my website that I would like to share
with all pages, even those in my /admin and /client directories. But when
pages in the subdir's are viewed the img, css, etc... references are
incorrect because they are "root based". Any suggestion as to how to
overcome this? Or do I have to create another Master Page for the subdir
pages?

Thansk!

Jun 27 '08 #2
Thanks for the info.

I tried both ~/path/ and /path/ and in IE and Firefox it shows up as a emtpy
box with a x in it.

Actual html image portion was as follows...
<img alt="My Picture" src="/resources/banner.jpg" width="780"
height="124" />

Any ideas? Thanks!

"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:OH**************@TK2MSFTNGP06.phx.gbl...
You are obviously using relative URLs in your code, which is good, but
when files in different directories are involved in the same page, it is
good to make sure they will all work for that page (and all pages they are
used in). Here are a few ideas that may help:

1. For directories that are used by almost all pages (and Master pages and
UserControls), such as an /images/ directory for example, it is good to
write it as /images/ rather than images/ so that it is relative to the
root instead of the current directory. This will save you the trouble of
needing to worry about whether to use the directory of the Page, Master
Page, UserControl, CSS file, JavaScript file, etc.

2. For any server controls, you can use ~/path/ The ~ represents the root
of the site. For more details on this, see the documentation.

Even though this may sometimes make your URLs longer than is always
absolutely necessary, it can usually save you a lot of trouble and make it
easier to modify code later in development. Hopefully some of this helps.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Cirene" <ci****@nowhere.comwrote in message
news:ud**************@TK2MSFTNGP02.phx.gbl...
>>I have 1 master page in the root of my website that I would like to share
with all pages, even those in my /admin and /client directories. But when
pages in the subdir's are viewed the img, css, etc... references are
incorrect because they are "root based". Any suggestion as to how to
overcome this? Or do I have to create another Master Page for the subdir
pages?

Thansk!


Jun 27 '08 #3
Is there any URL you can enter directly into the address bar that is the URL
of the file (such as http://localhost:49646/resources/banner.jpg) that will
display the image? If there is, what is it? Did you double-check to make
sure the file is really where you think it is? (NOTE: The ~/path/ technique
only works with server-side controls, so it would not work with the img tag
example you included)
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Cirene" <ci****@nowhere.comwrote in message
news:OH**************@TK2MSFTNGP04.phx.gbl...
Thanks for the info.

I tried both ~/path/ and /path/ and in IE and Firefox it shows up as a
emtpy box with a x in it.

Actual html image portion was as follows...
<img alt="My Picture" src="/resources/banner.jpg" width="780"
height="124" />

Any ideas? Thanks!

"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:OH**************@TK2MSFTNGP06.phx.gbl...
>You are obviously using relative URLs in your code, which is good, but
when files in different directories are involved in the same page, it is
good to make sure they will all work for that page (and all pages they
are used in). Here are a few ideas that may help:

1. For directories that are used by almost all pages (and Master pages
and UserControls), such as an /images/ directory for example, it is good
to write it as /images/ rather than images/ so that it is relative to the
root instead of the current directory. This will save you the trouble of
needing to worry about whether to use the directory of the Page, Master
Page, UserControl, CSS file, JavaScript file, etc.

2. For any server controls, you can use ~/path/ The ~ represents the root
of the site. For more details on this, see the documentation.

Even though this may sometimes make your URLs longer than is always
absolutely necessary, it can usually save you a lot of trouble and make
it easier to modify code later in development. Hopefully some of this
helps.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Cirene" <ci****@nowhere.comwrote in message
news:ud**************@TK2MSFTNGP02.phx.gbl...
>>>I have 1 master page in the root of my website that I would like to share
with all pages, even those in my /admin and /client directories. But
when pages in the subdir's are viewed the img, css, etc... references are
incorrect because they are "root based". Any suggestion as to how to
overcome this? Or do I have to create another Master Page for the subdir
pages?

Thansk!



Jun 27 '08 #4
If this problem is occurring while you are debugging your site it could be
because when you run your site from the debugger on local host there is an
additional 'www' path that is added to the url..

for example the path: http://localhost:49646/resources/banner.jpg
would turn into: http://localhost:49646/www/resources/banner.jpg

So. In debug mode your path would have to be /www/path/ instead of just
/path/ but once you have your site on the server it would be just /path
without the www.

I found that a good way to work with this is to set up your local IIS to
point to the site you are currently working on.. that way you can just go to
your browser and type in http://localhost or 127.0.0.1 and you will be able
to see what your site will look like. This will help reduce your development
time too.

I know... what a pain huh?

Jeremy Shovan
"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:#c**************@TK2MSFTNGP04.phx.gbl...
Is there any URL you can enter directly into the address bar that is the
URL of the file (such as http://localhost:49646/resources/banner.jpg) that
will display the image? If there is, what is it? Did you double-check to
make sure the file is really where you think it is? (NOTE: The ~/path/
technique only works with server-side controls, so it would not work with
the img tag example you included)
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Cirene" <ci****@nowhere.comwrote in message
news:OH**************@TK2MSFTNGP04.phx.gbl...
>Thanks for the info.

I tried both ~/path/ and /path/ and in IE and Firefox it shows up as a
emtpy box with a x in it.

Actual html image portion was as follows...
<img alt="My Picture" src="/resources/banner.jpg" width="780"
height="124" />

Any ideas? Thanks!

"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:OH**************@TK2MSFTNGP06.phx.gbl...
>>You are obviously using relative URLs in your code, which is good, but
when files in different directories are involved in the same page, it is
good to make sure they will all work for that page (and all pages they
are used in). Here are a few ideas that may help:

1. For directories that are used by almost all pages (and Master pages
and UserControls), such as an /images/ directory for example, it is good
to write it as /images/ rather than images/ so that it is relative to
the root instead of the current directory. This will save you the
trouble of needing to worry about whether to use the directory of the
Page, Master Page, UserControl, CSS file, JavaScript file, etc.

2. For any server controls, you can use ~/path/ The ~ represents the
root of the site. For more details on this, see the documentation.

Even though this may sometimes make your URLs longer than is always
absolutely necessary, it can usually save you a lot of trouble and make
it easier to modify code later in development. Hopefully some of this
helps.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Cirene" <ci****@nowhere.comwrote in message
news:ud**************@TK2MSFTNGP02.phx.gbl...
I have 1 master page in the root of my website that I would like to
share with all pages, even those in my /admin and /client directories.
But when pages in the subdir's are viewed the img, css, etc...
references are incorrect because they are "root based". Any suggestion
as to how to overcome this? Or do I have to create another Master Page
for the subdir pages?

Thansk!


Jun 27 '08 #5
The root path operator will function with anything marked runat="server"

"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Is there any URL you can enter directly into the address bar that is the
URL of the file (such as http://localhost:49646/resources/banner.jpg) that
will display the image? If there is, what is it? Did you double-check to
make sure the file is really where you think it is? (NOTE: The ~/path/
technique only works with server-side controls, so it would not work with
the img tag example you included)
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Cirene" <ci****@nowhere.comwrote in message
news:OH**************@TK2MSFTNGP04.phx.gbl...
>Thanks for the info.

I tried both ~/path/ and /path/ and in IE and Firefox it shows up as a
emtpy box with a x in it.

Actual html image portion was as follows...
<img alt="My Picture" src="/resources/banner.jpg" width="780"
height="124" />

Any ideas? Thanks!

"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:OH**************@TK2MSFTNGP06.phx.gbl...
>>You are obviously using relative URLs in your code, which is good, but
when files in different directories are involved in the same page, it is
good to make sure they will all work for that page (and all pages they
are used in). Here are a few ideas that may help:

1. For directories that are used by almost all pages (and Master pages
and UserControls), such as an /images/ directory for example, it is good
to write it as /images/ rather than images/ so that it is relative to
the root instead of the current directory. This will save you the
trouble of needing to worry about whether to use the directory of the
Page, Master Page, UserControl, CSS file, JavaScript file, etc.

2. For any server controls, you can use ~/path/ The ~ represents the
root of the site. For more details on this, see the documentation.

Even though this may sometimes make your URLs longer than is always
absolutely necessary, it can usually save you a lot of trouble and make
it easier to modify code later in development. Hopefully some of this
helps.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Cirene" <ci****@nowhere.comwrote in message
news:ud**************@TK2MSFTNGP02.phx.gbl...
I have 1 master page in the root of my website that I would like to
share with all pages, even those in my /admin and /client directories.
But when pages in the subdir's are viewed the img, css, etc...
references are incorrect because they are "root based". Any suggestion
as to how to overcome this? Or do I have to create another Master Page
for the subdir pages?

Thansk!


Jun 27 '08 #6
I tried both and they didn't work in both browsers. Maybe my PC is
possessed! :-x

"clintonG" <no****@nowhere.comwrote in message
news:OC**************@TK2MSFTNGP02.phx.gbl...
The root path operator will function with anything marked runat="server"

"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>Is there any URL you can enter directly into the address bar that is the
URL of the file (such as http://localhost:49646/resources/banner.jpg)
that will display the image? If there is, what is it? Did you
double-check to make sure the file is really where you think it is?
(NOTE: The ~/path/ technique only works with server-side controls, so it
would not work with the img tag example you included)
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Cirene" <ci****@nowhere.comwrote in message
news:OH**************@TK2MSFTNGP04.phx.gbl...
>>Thanks for the info.

I tried both ~/path/ and /path/ and in IE and Firefox it shows up as a
emtpy box with a x in it.

Actual html image portion was as follows...
<img alt="My Picture" src="/resources/banner.jpg" width="780"
height="124" />

Any ideas? Thanks!

"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:OH**************@TK2MSFTNGP06.phx.gbl...
You are obviously using relative URLs in your code, which is good, but
when files in different directories are involved in the same page, it
is good to make sure they will all work for that page (and all pages
they are used in). Here are a few ideas that may help:

1. For directories that are used by almost all pages (and Master pages
and UserControls), such as an /images/ directory for example, it is
good to write it as /images/ rather than images/ so that it is relative
to the root instead of the current directory. This will save you the
trouble of needing to worry about whether to use the directory of the
Page, Master Page, UserControl, CSS file, JavaScript file, etc.

2. For any server controls, you can use ~/path/ The ~ represents the
root of the site. For more details on this, see the documentation.

Even though this may sometimes make your URLs longer than is always
absolutely necessary, it can usually save you a lot of trouble and make
it easier to modify code later in development. Hopefully some of this
helps.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Cirene" <ci****@nowhere.comwrote in message
news:ud**************@TK2MSFTNGP02.phx.gbl...
>I have 1 master page in the root of my website that I would like to
>share with all pages, even those in my /admin and /client directories.
>But when pages in the subdir's are viewed the img, css, etc...
>references are incorrect because they are "root based". Any suggestion
>as to how to overcome this? Or do I have to create another Master Page
>for the subdir pages?
>
Thansk!
>



Jun 27 '08 #7
Do you have a response to my question about whether there is a URL for the
file you can enter directly into the address bar that will display the
image?
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Cirene" <ci****@nowhere.comwrote in message
news:es**************@TK2MSFTNGP06.phx.gbl...
>I tried both and they didn't work in both browsers. Maybe my PC is
possessed! :-x

"clintonG" <no****@nowhere.comwrote in message
news:OC**************@TK2MSFTNGP02.phx.gbl...
>The root path operator will function with anything marked runat="server"

"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>>Is there any URL you can enter directly into the address bar that is the
URL of the file (such as http://localhost:49646/resources/banner.jpg)
that will display the image? If there is, what is it? Did you
double-check to make sure the file is really where you think it is?
(NOTE: The ~/path/ technique only works with server-side controls, so it
would not work with the img tag example you included)
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Cirene" <ci****@nowhere.comwrote in message
news:OH**************@TK2MSFTNGP04.phx.gbl...
Thanks for the info.

I tried both ~/path/ and /path/ and in IE and Firefox it shows up as a
emtpy box with a x in it.

Actual html image portion was as follows...
<img alt="My Picture" src="/resources/banner.jpg" width="780"
height="124" />

Any ideas? Thanks!

"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:OH**************@TK2MSFTNGP06.phx.gbl...
You are obviously using relative URLs in your code, which is good, but
when files in different directories are involved in the same page, it
is good to make sure they will all work for that page (and all pages
they are used in). Here are a few ideas that may help:
>
1. For directories that are used by almost all pages (and Master pages
and UserControls), such as an /images/ directory for example, it is
good to write it as /images/ rather than images/ so that it is
relative to the root instead of the current directory. This will save
you the trouble of needing to worry about whether to use the directory
of the Page, Master Page, UserControl, CSS file, JavaScript file, etc.
>
2. For any server controls, you can use ~/path/ The ~ represents the
root of the site. For more details on this, see the documentation.
>
Even though this may sometimes make your URLs longer than is always
absolutely necessary, it can usually save you a lot of trouble and
make it easier to modify code later in development. Hopefully some of
this helps.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
>
"Cirene" <ci****@nowhere.comwrote in message
news:ud**************@TK2MSFTNGP02.phx.gbl.. .
>>I have 1 master page in the root of my website that I would like to
>>share with all pages, even those in my /admin and /client directories.
>>But when pages in the subdir's are viewed the img, css, etc...
>>references are incorrect because they are "root based". Any
>>suggestion as to how to overcome this? Or do I have to create another
>>Master Page for the subdir pages?
>>
>Thansk!
>>
>
>



Jun 27 '08 #8
I want to do everything relative if possible. If I put the image on my
website it will probably work, yes. But, i want it to be relative. Thanks.
"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:eD**************@TK2MSFTNGP03.phx.gbl...
Do you have a response to my question about whether there is a URL for the
file you can enter directly into the address bar that will display the
image?
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Cirene" <ci****@nowhere.comwrote in message
news:es**************@TK2MSFTNGP06.phx.gbl...
>>I tried both and they didn't work in both browsers. Maybe my PC is
possessed! :-x

"clintonG" <no****@nowhere.comwrote in message
news:OC**************@TK2MSFTNGP02.phx.gbl...
>>The root path operator will function with anything marked runat="server"

"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl.. .
Is there any URL you can enter directly into the address bar that is
the URL of the file (such as
http://localhost:49646/resources/banner.jpg) that will display the
image? If there is, what is it? Did you double-check to make sure the
file is really where you think it is? (NOTE: The ~/path/ technique only
works with server-side controls, so it would not work with the img tag
example you included)
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Cirene" <ci****@nowhere.comwrote in message
news:OH**************@TK2MSFTNGP04.phx.gbl...
Thanks for the info.
>
I tried both ~/path/ and /path/ and in IE and Firefox it shows up as a
emtpy box with a x in it.
>
Actual html image portion was as follows...
<img alt="My Picture" src="/resources/banner.jpg" width="780"
height="124" />
>
Any ideas? Thanks!
>
"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:OH**************@TK2MSFTNGP06.phx.gbl.. .
>You are obviously using relative URLs in your code, which is good,
>but when files in different directories are involved in the same
>page, it is good to make sure they will all work for that page (and
>all pages they are used in). Here are a few ideas that may help:
>>
>1. For directories that are used by almost all pages (and Master
>pages and UserControls), such as an /images/ directory for example,
>it is good to write it as /images/ rather than images/ so that it is
>relative to the root instead of the current directory. This will save
>you the trouble of needing to worry about whether to use the
>directory of the Page, Master Page, UserControl, CSS file, JavaScript
>file, etc.
>>
>2. For any server controls, you can use ~/path/ The ~ represents the
>root of the site. For more details on this, see the documentation.
>>
>Even though this may sometimes make your URLs longer than is always
>absolutely necessary, it can usually save you a lot of trouble and
>make it easier to modify code later in development. Hopefully some of
>this helps.
>--
>Nathan Sokalski
>nj********@hotmail.com
>http://www.nathansokalski.com/
>>
>"Cirene" <ci****@nowhere.comwrote in message
>news:ud**************@TK2MSFTNGP02.phx.gbl. ..
>>>I have 1 master page in the root of my website that I would like to
>>>share with all pages, even those in my /admin and /client
>>>directories. But when pages in the subdir's are viewed the img, css,
>>>etc... references are incorrect because they are "root based". Any
>>>suggestion as to how to overcome this? Or do I have to create
>>>another Master Page for the subdir pages?
>>>
>>Thansk!
>>>
>>
>>
>
>



Jun 27 '08 #9

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

Similar topics

4
by: Tony Liu | last post by:
Hi, how can I create multiple new file handles of a file without having to share to file to the other processes? I have a file that will be accessed by multiple threads in my application, each...
4
by: JP | last post by:
Hello, this is an asp.net 2.0 question. I have a project that holds a master page. I want to use the same masterpage in another web project. It seems like this is not possible. Anybody know...
20
by: Alan Silver | last post by:
Hello, In classic ASP, I used to use two include files on each page, one before and one after the main content, to provide a consistent layout across a web site. That way I could just change the...
1
by: Fred Nelson | last post by:
I have a question regarding page caching in a C# Web App that I'm developing. I have used page caching successfully in VS2003 at the page level - and it also works the same in VS2005. I have...
5
by: Kevin | last post by:
We currently have a 1.1 class library which houses the look and feel of our website by creating the html form dynamically in a base class. We then distribute our assembly to other application...
4
by: Boris Yeltsin | last post by:
OK, on my Master Page I have a control: <a id="hypTabAccount" href="#" runat="server">Account</a> Now, in the code-behind (Root.master.vb) I can refer to it simply thus: ...
2
by: n# | last post by:
I have an old existing website with a Header/ Left Hand Menu and a iframe as the main body content, adjacent to the menu. So for every click on the menu item, I used to load a aspx page on the...
4
by: lichaoir | last post by:
I have two questions about the use of Master Page: 1. How to access properties and controls in the master page from content page? (I know I can use the "FindControl()" method of the "Master"...
5
by: Murray | last post by:
Forgive me if this question is too basic, but I'm new to ASP.NET programming, and I can't locate a simple answer to this question. I have a web page that consists of a Master Page and a single...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.