Master page from SubFloders

I

IfThenElse

Hi,

I have a web page in a subfolder that inherits a Master page at the root.

the webpage in the subfolder can not see the Master page.

This is what I have in my webPageThatIsInSubfolder.aspx
MasterPageFile="~/myMasterPage.Master"

Tried,

MasterPageFile="../vendor.Master" Does not work



Where should a Master Page be placed, in what folder.



Thanks
 
S

Shelly

IfThenElse said:
Tried,

MasterPageFile="../myMasterPage" Does not work

I have the same thing and this form worked for me. My page is in the
/manage subfolder and the master page is in the root folder (one above). I
have MasterPageFile="~/Managing.master" and it works fine.

Shelly
 
I

IfThenElse

I am in Error, Sorry I found out that my images in my Master Page do not
show up.

What gives???
 
S

Shelly

IfThenElse said:
Tried,

MasterPageFile="../myMasterPage" Does not work

Aha! is your master file called myMasterPage.Master or is it
myMasterPage.master ??

Shelly
 
I

IfThenElse

I am in Error, Sorry I found out that my images in my Master Page do not
show up.

What gives???
 
I

IfThenElse

I have typed the name wrong. Just a typo
MasterPageFile="~/myMasterPage.Master"

I am in Error, Sorry I found out that my images in my Master Page do not
show up.

What gives???
 
I

IfThenElse

It looks like an absolute URL is needed in a Master Page. Why?

Now when I move all my Master Pages to Production I have to change all the
URLs of all the Images in all master pages for my website.
Is there a trick around this?

Thanks,

IfThenElse
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

IfThenElse said:
I am in Error, Sorry I found out that my images in my Master Page do not
show up.

What gives???

Becase you refer to them relative to the root folder, but the browser
look for them relative to the folder where the page is.

The browser have no idea where the master page is, or even that there is
a master page at all.
 
I

IfThenElse

Goran,

I am talking about before the browser gets the markup.
ASP.NET is not dishing out the correct URL path for the images

So what is the solution other than absolute URL?
 
M

Mark Rae [MVP]

It looks like an absolute URL is needed in a Master Page. Why?

Now when I move all my Master Pages to Production I have to change all the
URLs of all the Images in all master pages for my website.
Is there a trick around this?

Yes - do this...

<root>
default.aspx
web.config
\folder1
file1.aspx
file2.aspx
\folder2
file1.aspx
file1.aspx
\images
image1.jpg
image2.jpg
\home
default.aspx
\master
default.master

Then, no matter where you are, your MasterPage is always
.../master/default.master and your images are always ../images/image1.jpg
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

IfThenElse said:
Goran,

I am talking about before the browser gets the markup.
ASP.NET is not dishing out the correct URL path for the images

So what is the solution other than absolute URL?

Well, unless there is something seriously wrong with your setup, it's
dishing out exactly the URL that you tell it to.

How do you specify the URLs, where are the images, and what's wrong with
the URLs that are generated?
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

IfThenElse said:
It looks like an absolute URL is needed in a Master Page. Why?

Not at all. You can use an URL that is relative to the page or one that
is relative to the root. If you specify an url in css, it's relative to
the css file.
Now when I move all my Master Pages to Production I have to change all the
URLs of all the Images in all master pages for my website.
Is there a trick around this?

The trick is simply to not use absolute URLs.
 
I

IfThenElse

Okay,

Found solution/problem

Now I feel dumb and stupid: I was using html <img> tag instead of server
<asp:image />
After switching to <asp:image> server tags the "~/images/myimage.jpg" shows
up all over.

please stand by for another stupid question, coming to a browser before you.

Thanks all
 
M

Mike Placentra II

When you are setting an absolute path in a property on a control, you
can have ASP.net deal with it.

Just use your tilde and then the root-relative file location as you do
to set Page's MasterPageFile. If it's just a normal HTML element, add
runat="server" (might as well use Image control in this example):

<img alt="" src="~/stuff/it.png" id="picofitImg" runat="server" />

Or you can do it relative to the master page when setting it on the
master page in a control:

<link rel="stylesheet" type="text/css" href="navstyles.css"
id="navStylesLink" runat="server" />

This will yield the results you were expecting before; ASP.net would
not touch the paths that are not in server controls. Try to look out
for times when you might be able to do it with a relative path instead
of an absolute path, IE when setting a background image from a CSS
file as Göran said.

-Michael Placentra II
 

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,813
Latest member
lawrwtwinkle111

Latest Threads

Top