母版页问题

时间:2011-07-04 10:56:40

标签: asp.net

<%@ Master Language="VB" CodeFile="Main.master.vb" Inherits="Main" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="CSS_Styles/twoColFixLtHdr.css" rel="stylesheet" type="text/css" />
    <link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
    <script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
     <script type="text/javascript">
         function callAlert(msg) {
             alert(msg);
         }
    </script>
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    </asp:ToolkitScriptManager>
    <asp:ContentPlaceHolder ID="ScriptManager" runat="server">

    </asp:ContentPlaceHolder>
    <div class="container">
     <div class="header">

      &nbsp;<asp:LoginStatus ID="LoginStatus1" runat="server" 
                                             ForeColor="White" 
                                             CssClass="signin"  Font-Size="Small"/>
          <asp:LoginView ID="LoginView1" runat="server">
          <AnonymousTemplate>
          <asp:HyperLink ID="HyperLink1" runat="server" 
                                         CssClass="register" 
                                         ForeColor="White" 
                                         NavigateUrl="~/login.aspx" Font-Size="Small">Register</asp:HyperLink>


          </AnonymousTemplate>
          <LoggedInTemplate>
          <asp:HyperLink ID="HyperLink2" runat="server" 
                                         NavigateUrl="~/account.aspx" 
                                         ForeColor="White" 
                                         CssClass="myaccount" Font-Size="Small">My Account</asp:HyperLink>
          <asp:HyperLink ID="HyperLink5" runat="server" 
                                         NavigateUrl="~/fleaMarket/fleaMarketAccount.aspx" 
                                         ForeColor="White" 
                                         CssClass="fleaaccount" Font-Size="Small">Flea Account</asp:HyperLink>

          <asp:HyperLink ID="HyperLink3" runat="server" 
                                         NavigateUrl="~/admin/access/access_rule_summary.aspx" 
                                         ForeColor="White" 
                                         CssClass="myaccount" Visible="false" Font-Size="Small">Admin</asp:HyperLink>
          <asp:HyperLink ID="HyperLink4" runat="server" 
                                         NavigateUrl="~/report.aspx" 
                                         ForeColor="White" 
                                         CssClass="myaccount" Visible="false" Font-Size="Small">Report</asp:HyperLink>                                                        

          </LoggedInTemplate>
          </asp:LoginView>                                   
                  <br />

                  <div id="CartAr">
                      <asp:Panel ID="Panel2" runat="server" Width="300px" Height="82px" BackColor="#ffffff">
                          <asp:Image ID="imgShpngCrt" runat="server" ImageUrl="~/Images/cart image1.jpg" Width="90px" Height="82px" CssClass="fltlft1" />
                          <asp:LoginView ID="LoginView2" runat="server">
                          <AnonymousTemplate>
                          <asp:Label ID="Label2" runat="server"  
                                 ForeColor="Black" 
                                 CssClass="" Font-Size="Small">Welcome!Guest.
                          </asp:Label>
                          </AnonymousTemplate>
                          <LoggedInTemplate>
                          <asp:Label ID="Label2" runat="server"  
                                 ForeColor="Black" 
                                 CssClass="" Font-Size="Small">Welcome! <asp:LoginName ID="LoginName2" runat="server" />
                          </asp:Label>       
                          </LoggedInTemplate>
                          </asp:LoginView><br />
                          <div style="float:left; font-size:small;">
                          <asp:Label ID="lblCartItem" runat="server" Text="Items in your cart :" ForeColor="Black" Font-Size="Small"></asp:Label>
                          </div>
                          <asp:UpdatePanel ID="UpdatePanelMaster" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="True">
                          <ContentTemplate>
                          <div style="float:left; font-size:small;">
                              <asp:Label ID="lblcartitemcount" runat="server" Text="hahahah"></asp:Label>
                          </div>    
                          </ContentTemplate>
                          </asp:UpdatePanel>
                          <br /><br />
                          <asp:LinkButton ID="LinkButton1" runat="server" ForeColor="#336699" CssClass="textdeco" Font-Size="Small">View Cart</asp:LinkButton>
                          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                          </asp:Panel>



                  </div>




    <!-- end .header --></div>
<div id="navPos">
    <ul id="MenuBar1" class="MenuBarHorizontal">
  <li>
      <asp:HyperLink ID="Home" runat="server" NavigateUrl="~/index.aspx">Home&nbsp;&nbsp;|</asp:HyperLink>
  </li>
  <li>
      <asp:HyperLink ID="Products" runat="server" CssClass="MenuBarItemSubmenu">Products</asp:HyperLink>
      <ul>
      <li><asp:HyperLink ID="Groceries" runat="server">Groceries</asp:HyperLink></li>
      <li><asp:HyperLink ID="DepartmentalItems" runat="server">Departmental Items</asp:HyperLink></li>
      <li><asp:HyperLink ID="Electronics" runat="server">Electronics</asp:HyperLink>
      <ul>
      <li><asp:HyperLink ID="Mobiles" runat="server" NavigateUrl="~/itemsDisplayPage_aspx/itemsDisplayPage.aspx?typeOfItem=mobiles">Mobiles</asp:HyperLink></li>
      <li><asp:HyperLink ID="Laptops" runat="server" NavigateUrl="~/itemsDisplayPage_aspx/itemsDisplayPage.aspx?typeOfItem=computers">Laptops &amp; Computers</asp:HyperLink></li>
      <li><asp:HyperLink ID="Accessories" runat="server">Accessories</asp:HyperLink></li>
      </ul>      
      </li>
      <li><asp:HyperLink ID="Kitchen" runat="server">Kitchen Items</asp:HyperLink></li>
      <li><asp:HyperLink ID="HyperLink6" runat="server">Home Appliances</asp:HyperLink></li>
      <li><asp:HyperLink ID="HyperLink7" runat="server">Fasion</asp:HyperLink></li>
    </ul>     
  </li>
  <li><asp:HyperLink ID="AboutUs" runat="server" NavigateUrl="~/Restaurant.aspx">|&nbsp;&nbsp;Restaurant Offers&nbsp;&nbsp;|</asp:HyperLink></li>
  <li><asp:LinkButton ID="cmdMedicine" runat="server">Buy Medicines&nbsp;&nbsp;|</asp:LinkButton></li>
  <li><asp:HyperLink ID="FleaMarket" runat="server" NavigateUrl="~/fleaMarket/fleaBazaar.aspx">Flea Market&nbsp;&nbsp;|</asp:HyperLink></li>
  <li><asp:HyperLink ID="SellItems" runat="server" NavigateUrl="~/fleaMarket/hostItem.aspx">Sell Items&nbsp;&nbsp;|</asp:HyperLink></li>
  <li><asp:HyperLink ID="WhyUS" runat="server">Why Us&nbsp;&nbsp;|</asp:HyperLink></li>
  <li><asp:HyperLink ID="Payment" runat="server">Payment&nbsp;&nbsp;|</asp:HyperLink></li>
  <li><asp:HyperLink ID="Contact_Us" runat="server" NavigateUrl="~/ContactUs.aspx">Contact Us</asp:HyperLink></li>

</ul>


    </div><br /><br />
        <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">

        </asp:ContentPlaceHolder>
 <div class="footer">
      <asp:TextBox ID="txtSubscribe" runat="server"></asp:TextBox>
      <asp:Button ID="cmdSubscribe" runat="server" Text="Subscribe" /><br />
  <div style="text-align:center; font-size:small;">
   <a href="#">About Us</a>&nbsp;|<a href="#">Payment Options</a>&nbsp;|<a href="#">Terms &amp; 
      Conditions</a>&nbsp;|<a href="#">Return Policy </a>&nbsp;|<a href="#">Privacy Policy</a>&nbsp;&nbsp;©TriceDeals.Com 
      2011.
    </div>
    <!-- end .footer --></div>
  <!-- end .container --></div>
  <asp:ContentPlaceHolder ID="AfterFooter" runat="server">


  </asp:ContentPlaceHolder>
  <script type="text/javascript">
      var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", { imgDown: "SpryAssets/SpryMenuBarDownHover.gif", imgRight: "SpryAssets/SpryMenuBarRightHover.gif" });
</script>
    </form>
</body>
</html>

这是我的母版页面...我在我的网站上有一个下拉导航,我已放入母版页...所以现在问题是“导航菜单的下拉属性在某些页面中正常工作并且在某些工作中不起作用...为什么会发生这种情况?如果我不使用母版页,则菜单在所有页面中都有效。

1 个答案:

答案 0 :(得分:1)

您必须使用波浪号(〜)来获取应用程序的根目录,因为某些页面可能位于子目录中,因此具有与其他页面相比的Styles / Scripts的另一个相对路径(@Aristos解决方案仅适用对于第一级子目录。)

您只能在服务器控件上使用~,因此请在链接标记上添加runat=server

<link runat="server" href="~/CSS_Styles/twoColFixLtHdr.css" rel="stylesheet" type="text/css" />
<link runat="server" hef="~/SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />

要获得对脚本文件的正确引用,您必须添加ScriptReferences:

<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
   <Scripts>
      <asp:ScriptReference Path="~/SpryAssets/SpryMenuBar.js" />
   </Scripts>
</asp:ToolkitScriptManager>