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

How does master pages in aspnet2.0 do it?

In asp.net 2.0, when using master pages the paths to images, styles sheets
etc get fixed appropriately depeing on whether the child page is in a
subfolder or not. How does master pages do it? Cani implement htis somehow
in 1.1? I have been playing with the templating solution present in the
aspnet insider tricks.Migh it be possible to add the behavior to that
approach somehow?

Thanks
Ashok

Nov 19 '05 #1
6 1244
The relative paths in ASP.NET 2.0 are the same as ASP.NET 1.1 -- anytime
you have a server side control that has a server side resource, use the "~"
syntax to build a relative path to the resource.

<asp:Image runat=server ImageUrl="~/images/foo.gif" />

-Brock
http://staff.develop.com/ballen
In asp.net 2.0, when using master pages the paths to images, styles
sheets etc get fixed appropriately depeing on whether the child page
is in a subfolder or not. How does master pages do it? Cani implement
htis somehow in 1.1? I have been playing with the templating solution
present in the aspnet insider tricks.Migh it be possible to add the
behavior to that approach somehow?

Thanks
Ashok


Nov 19 '05 #2
There are a few people that have "reverse engineered" the idea and put it in
their software. I believe Dot Net Nuke is one of the projects that has done
this.
---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************

"Showjumper" wrote:
In asp.net 2.0, when using master pages the paths to images, styles sheets
etc get fixed appropriately depeing on whether the child page is in a
subfolder or not. How does master pages do it? Cani implement htis somehow
in 1.1? I have been playing with the templating solution present in the
aspnet insider tricks.Migh it be possible to add the behavior to that
approach somehow?

Thanks
Ashok

Nov 19 '05 #3
In the earlier betas (have not played as deeply with the CTPs), the ~ was hit
or miss with master pages.
---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************

"Brock Allen" wrote:
The relative paths in ASP.NET 2.0 are the same as ASP.NET 1.1 -- anytime
you have a server side control that has a server side resource, use the "~"
syntax to build a relative path to the resource.

<asp:Image runat=server ImageUrl="~/images/foo.gif" />

-Brock
http://staff.develop.com/ballen
In asp.net 2.0, when using master pages the paths to images, styles
sheets etc get fixed appropriately depeing on whether the child page
is in a subfolder or not. How does master pages do it? Cani implement
htis somehow in 1.1? I have been playing with the templating solution
present in the aspnet insider tricks.Migh it be possible to add the
behavior to that approach somehow?

Thanks
Ashok


Nov 19 '05 #4
> In the earlier betas (have not played as deeply with the CTPs), the ~
was hit or miss with master pages.


It works properly with the 2004 Nov CTP. This better work in RTM, otherwise
it will be very difficult to reference resources from a master. :)

-Brock
http://staff.develop.com/ballen


Nov 19 '05 #5
This approach however doesnt work stylesheets even when giving the runat
attr. to the <link> tag. Would an option be to make a custom control that
emits the <link> tag? Would it then handle the ~?
"Brock Allen" <ba****@develop.com.i_hate_spam_too> wrote in message
news:64********************@msnews.microsoft.com.. .
The relative paths in ASP.NET 2.0 are the same as ASP.NET 1.1 -- anytime
you have a server side control that has a server side resource, use the
"~" syntax to build a relative path to the resource.

<asp:Image runat=server ImageUrl="~/images/foo.gif" />

-Brock
http://staff.develop.com/ballen
In asp.net 2.0, when using master pages the paths to images, styles
sheets etc get fixed appropriately depeing on whether the child page
is in a subfolder or not. How does master pages do it? Cani implement
htis somehow in 1.1? I have been playing with the templating solution
present in the aspnet insider tricks.Migh it be possible to add the
behavior to that approach somehow?

Thanks
Ashok



Nov 19 '05 #6
> This approach however doesnt work stylesheets even when giving the
runat
attr. to the <link> tag. Would an option be to make a custom control
that
emits the <link> tag? Would it then handle the ~?


I'm running the 2004 Nov CTP and this works for me:

<head runat="server">
<link rel="stylesheet" href="~/CSS/Stylesheet.css" type="text/css" />
</head>

-Brock
http://staff.develop.com/ballen

Nov 19 '05 #7

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

Similar topics

1
by: Sasha | last post by:
Hi all asp.net proffesionals out there, How do you implement master pages in your applications? What libraries do you use and what have been your experience? Sasha
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: Alan Silver | last post by:
Hello, I am just experimenting with master pages, and am trying to add a content placeholder in the <head> section, so that individual pages can set their own page title and meta tags. The...
4
by: Mark Olbert | last post by:
I have a website (ASPNET2) where the master page has a button in it and my login page, which is a detail page of the master page, also has a button (a login button). Everything works fine if I...
3
by: Mark Olbert | last post by:
I have some img tags on a master page which reference files in a top-level directory. They look like this: <img src="assets/test.gif" id="gnr" /> assets is a subdirectory of the website root. ...
17
by: Rob R. Ainscough | last post by:
Again another simple concept that appears NOT to be intuitive or I'm just stupid. I've read the WROX book and the example doesn't actually show how the .master page links in the other content...
7
by: xkeops | last post by:
Thinking of creating a website, most of the pages will have a general toolbar menu, a content and a footer. The content will be the only one who's gonna change but the rest (header,footer) will...
7
by: Dwight Johnson | last post by:
I am attempting to use Master Pages in a new website, and finding it troublesome. I also do not see a lot of entries in this group regarding them or their components, such as ContentPlaceHolders. ...
6
by: Mickey | last post by:
Coming from a Dreamweaver/ASP/PHP background. Planning to use Visual Studio 2008 for a website. Complete newbie question here (please be gentle!): Do master pages work similar to Dreamweaver...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.