用來對應包含與當前內容關聯的 ContentPlaceHolder 的 ID啊
說白了就是去找母版頁相應的ContentPlaceHolder ,然后把內容扔進那里面去
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <body>
你這個是調用母版頁,因為母版頁中已經有了<body>標簽了,所以這個子頁面就不需要此標簽了
ContentPlaceHolder1這個就是母版頁的ID,Content2是你這個子頁面的ID。不明白可以再問
內容頁ContentPlaceHolder里使用CSS
我想在內容頁里放個文本框和按鈕,然后讓他們並排,我加了CSS不行,網上查了說內容頁不能使用CSS好像,那應該怎么做才能讓他們並排呢?
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <div style="float:left; "> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> </div> <div style="float:left; "> <asp:Button ID="Button1" runat="server" Text="Button" /> </div>
內容頁可以使用CSS文件;前提是你在模板頁head標簽間挖個坑,然后這個坑專門用來寫樣式和腳本。
你那個漂浮只是在div所在的這個坑漂浮,能不能實現並排還得看你在模板頁面怎么挖的坑。
site.master關鍵部分
<head>
<title><asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title>
<link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
<asp:ContentPlaceHolder ID="IncludeContent" runat="server" />
</head>
<body>
...
在內容頁
<asp:Content ID="Content3" ContentPlaceHolderID="IncludeContent" runat="server"> <script type="text/javascript" src="../../Scripts/MicrosoftAjax.js"></script> <script type="text/javascript" src="../../Scripts/MicrosoftMvcValidation.js"></script> </asp:Content>
