Mega Code Archive

 
Categories / ASP.Net Tutorial / Development
 

Deal with the relative path between master page and content page

use the Page.ResolveUrl() method to translate an application relative URL into an absolute URL.  File: MasterPages\ImageMaster.master <%@ Master Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server">     <title>Image Master</title> </head> <body>     <form id="form1" runat="server">     <div>     <img src='<%=Page.ResolveUrl("~/MasterPages/Logo.gif") %>' alt="Website Logo" />     <asp:contentplaceholder id="ContentPlaceHolder1" runat="server" />     </div>     </form> </body> </html>