gpt4 book ai didi

css - 母版页不抓取 contentPlaceHolder 的样式

转载 作者:行者123 更新时间:2023-11-28 03:55:20 29 4
gpt4 key购买 nike

这是我第一次使用内容。我创建了一个包含所有样式等的完整 aspx 页面,它看起来像这样包含所有样式/ Bootstrap 等:

enter image description here

使用第一页作为引用,我将代码从中分离出来并将其复制到母版页中,并将所有导航栏代码移到 Default.aspx 页面中。

当我创建内容母版并添加代码时,它显示如下:

enter image description here

我不确定为什么没有显示样式等。一定是什么地方组织错了吗?

我什至尝试将 css 直接添加到 Master 中,但 css 仍然不起作用。

<%@ Master Language="VB" AutoEventWireup="false" CodeBehind="Site1.master.vb" Inherits="CherylsGroupWeb.Site1" %>

<!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>
<!-- Latest compiled and minified CSS -->
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet"/>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet nofollow" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"/>
<!-- jQuery library -->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="Index.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
$(document).ready(function () {
$('#menu-content li').click(function () {
$('#menu-content .active').removeClass('active'); // remove the class from the currently selected
$(this).addClass('active'); // add the class to the newly clicked link
});
</script>

<style>
<!-- put all css here to test as well -->
</style>

<asp:ContentPlaceHolder ID="head" runat="server">

</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div>

<asp:ContentPlaceHolder ID="topContent" runat="server">
<a href="Default.aspx">Master Pages Tutorials</a>

</asp:ContentPlaceHolder>

<asp:ContentPlaceHolder ID="MainContent" runat="server">

</asp:ContentPlaceHolder>

</div>
</form>
</body>
</html>

最佳答案

我不确定我的格式究竟是什么错误,但是通过将示例的结构复制到新的 Master 中并在我的 Default.aspx 周围添加内容,它显示了它。所以我删除了 <a>对于我的 Default.aspx

Default.aspx

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="GroupWeb._Default1" MasterPageFile="~/Site2.Master" %>


<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="topContent" runat="server">
<!-- my nav bar code --->
</asp:Content>

硕士

<body>
<form id="form1" runat="server">
<div id='mainBody'>
<h1>
How to use Master Pages in ASP.NET
</h1>
<br />
<b>This is a Master Page Content.</b>
<br />
<br />
<div>

<asp:ContentPlaceHolder ID="topContent" runat="server">

</asp:ContentPlaceHolder>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
<!-- ContentPlaceHolder is used to enable the pages which uses this page as master page, to place their contents -->
</asp:ContentPlaceHolder>
</div>
</div>
</form>
</body>

关于css - 母版页不抓取 contentPlaceHolder 的样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43496788/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com