Monday, May 08, 2006

URL Rebasing in MasterPages

Did you know about URL Rebasing in MasterPages? - I didn't.

Often, MasterPage and Slave (or ContentPage) are not located in the same directory-level. So you will run into trouble if you have for example images on the MasterPage referenced like this:

<IMG src="images/spice.jpg" />

The ContentPage in a SubDirectory can not resolve the URL and you will get an 404-Error.

What is the Solutions?

Just put an runat="server" and and id="yourID" attribut to the image and the runtime will try to “rebase” relative URLs it finds on server-side controls inside a MasterPage .

This means the following relative path will work, no matter where the MasterPages and ContentPage :

<IMG id="spiceImg" src="images/spice.jpg" runat="server"/>

Cool!

5 comments:

Anonymous said...

Good job; works nicely.

Anonymous said...

cheap wedding gowns,
discount bridal gowns,
China wedding dresses,
discount designer wedding dresses,
China wedding online store,
plus size wedding dresses,
cheap informal wedding dresses,
junior bridesmaid dresses,
cheap bridesmaid dresses,
maternity bridesmaid dresses,
discount flower girl gowns,
cheap prom dresses,
party dresses,
evening dresses,
mother of the bride dresses,
special occasion dresses,
cheap quinceanera dresses,
hot red wedding dresses

products said...

China Wholesalers has been described as the world’s factory. buy products wholesaleThis phenomenom is typified by the rise ofbusiness. Incredible range of products available with China Wholesale “Low Price and High Quality” not only reaches directly to their target clients worldwide but also ensures that wholesale from china from China means margins you cannot find elsewhere and China Wholesale will skyroket your profits.china wholesale productsbuy china wholesalewholesale chinawholesale productsbuy products

products said...

We offer designer , custom wedding dress, cheap cell phonescheap wedding dressesbridal gowns, wedding gowns, Flower Girl Dresses andwholesale cell phonesso on. Buy tailor-made anddesigner wedding dresses designer to be a special brides now!

products said...

Wholesale Gemstone cheap Gemstone Jewelry from China, discount wholesale jewelry Beads, wholesale Gemstone jewelry cheapest Wholesale Naruto anime and manga cheap cosplay costumes, cheap Naruto cosplay costumes on sale, buy Naruto cosplay naruto online shop.Wholesale anime and manga wholesale crystal jewelry costumes, cheap cosplay costumes on sale, buy anime cosplay costumes online shop