samedi, février 11, 2006

Master page referencing problem !

My first problem with the 2 master page was some url declration, i checked the solution from the msdn :
If you were to add a reference to the Check.gif image in the images directory from the Site.master in the masterpages directory, you might be tempted to add a simple image element, as shown here:
img src="../images/check.gif"
Unfortunately, this would only work for pages that were in a relative directory location similar to where the image as the Master Page was, like page1.aspx. Any other page, like default.aspx, would not correctly resolve the relative path. One solution to this is to use the root path reference syntax in ASP.NET and ensure that all relative references are made from server-side controls, which is the only place this syntax works. The image reference I mentioned earlier would become:
img src="~/images/check.gif" runat="server"
Another option is to rely on the fact that relative path references in server-side controls are evaluated relative to the Master Page in which they are placed. This means that it would also be sufficient to change the image reference to the following:
img src="../images/check.gif" runat="server"

Aucun commentaire: