主版頁面Master中Html控制項img,a,javascript,CSS相對路徑問題

來源:互聯網
上載者:User

1.<img>控制項 加上runat="server"

修改後:

<img src="images/footlogo.jpg" runat="server" />

2.<a>控制項  加上runat="server"

 

修改後:

<a href="Report/WCDMAHSDPA.aspx" runat="server">WCDMA HSDPA</a>

3.javascript

 

路徑的問題,加一段<%=Request.ApplicationPath %>

<script src="<%=Request.ApplicationPath %>sdmenu/sdmenu.js">

這樣添加指令碼的代碼不要放在head中,放到Body裡

 

1 .    MasterPage.master 中 head標籤中加入:<asp:ContentPlaceHolder ID="HeadHolder" runat="server">
                                                                                    </asp:ContentPlaceHolder> 

2.    在內容頁中加入

    <asp:Content ID="HeaderContent2" ContentPlaceHolderID="HeadHolder" runat="Server">
         <link rel="stylesheet" href="../css/layout.css" type="text/css" media="screen" />
        <script src="../js/jquery.tablesorter.min.js" type="text/javascript"></script> 

   </asp:Content> 這樣就可以將路徑指定到js和css的相對於內容頁的路徑了。

3.  Content 控制項 的ID要一樣哦!

 

1. 母板頁CSS:   <link rel="stylesheet" href="~/css/layout.css" type="text/css" media="screen" />  "~"符號即可

2. 母板頁JS:   <%= "<script type='text/javascript' src='"+ResolveUrl("~/js/jquery-1.5.2.min.js")+"'></script>"%>

3 .母板頁img     <img scr='<%=ResolveUrl("~/imges/logo.gif") %>'  />

 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.