【发布时间】:2017-06-03 19:50:24
【问题描述】:
好的。我正在使用 Visual Web Developer 制作一个学校项目,我需要使用母版页。当我基于我的母版页创建一个新的 Web 表单时,它继承了母版页的颜色,但是有一个没有被继承的表格。这是我的母版页代码:
<%@ Master Language="VB" CodeFile="Master1.master.vb" Inherits="Master1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server" background-color: #00FF00;>
<title></title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
<style type="text/css">
.auto-style2 {
height: 57px;
width: 2363px;
}
.auto-style3 {
height: 57px;
width: 48px;
}
.auto-style4 {
height: 48px;
}
.newStyle1 {
background-color: #FF00FF;
}
.auto-style5 {
width: 369px;
height: 214px;
}
</style>
</head>
<body style="background-color: blue;">
<form id="form1" runat="server">
<div class="newStyle1">
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
<table class="newStyle1">
<tr>
<td class="auto-style4" colspan="2">
<asp:Menu ID="Menu1" runat="server" Orientation="Horizontal">
<Items>
<asp:MenuItem NavigateUrl="Default.aspx" Text="Home" Value="Home"></asp:MenuItem>
<asp:MenuItem NavigateUrl="About.aspx" Text="About" Value="About"></asp:MenuItem>
</Items>
</asp:Menu>
</td>
</tr>
<tr>
<td class="auto-style3">
<img alt="CS Logo" class="auto-style5" src="cSk.png" /></td>
<td class="auto-style2">
<asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server">
</asp:ContentPlaceHolder>
</td>
</tr>
<tr>
<td class="auto-style4" colspan="2"></td>
</tr>
</table>
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
母版页 VB 代码:
Partial Class Master1
Inherits System.Web.UI.MasterPage
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
End Sub
End Class
Web Form Attempted to Inherit Master Page:
%@ Page Title="" Language="VB" MasterPageFile="~/Master1.master" %>
<script runat="server">
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
</asp:Content>
【问题讨论】:
-
尝试将脚本放入
ContentPlaceHolderID="head"? -
谢谢。通过将表格移到 div 之外解决了我自己的问题。
标签: vb.net webforms master-pages