我有一个ASP.NET项目,其页面以:
开头<head runat="server">
<meta charset="utf-8">
<title>Online SMS Choose</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<link id="Link1" rel="stylesheet" runat="server" media="screen" href="~/css/tableStyle.css" />
<link id="Link2" rel="stylesheet" runat="server" media="screen" href="~/css/LoadingStyle.css" />
<link id="Link3" rel="stylesheet" runat="server" media="screen" href="~/css/selectStyle.css" />
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script>
$(function () {
$("#tabs").tabs();
});
$(function () {
$("#datepicker").datepicker();
});
</script>
</head>
然后我的经理告诉我,我必须将该项目与另一项合并。她给了我另一个项目的代码。该代码中没有head
标记,但它在页面开头有此内容:
<%@ Page Title="Service Categories" Language="C#" MasterPageFile="~/Site.master"
AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="service._Default" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<script type="text/javascript" src="Scripts/ZeroClipboard.js"></script>
<script type="text/javascript" src="Scripts/main.js"></script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<div class="content" id="Content">
我在哪里将<head>
标记放在这个新项目中?
答案 0 :(得分:4)
您提供的第一个代码段是标准HTML标记,第二个是ASP.NET标记,我相信您已经知道。
您可以通过以下方式组合它们:
<%@ Page Title="Service Categories" Language="C#" MasterPageFile="~/Site.master"
AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="service._Default" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<script type="text/javascript" src="Scripts/ZeroClipboard.js"></script>
<script type="text/javascript" src="Scripts/main.js"></script>
<title>Online SMS Choose</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<link id="Link1" rel="stylesheet" runat="server" media="screen" href="~/css/tableStyle.css" />
<link id="Link2" rel="stylesheet" runat="server" media="screen" href="~/css/LoadingStyle.css" />
<link id="Link3" rel="stylesheet" runat="server" media="screen" href="~/css/selectStyle.css" />
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script>
$(function () {
$("#tabs").tabs();
});
$(function () {
$("#datepicker").datepicker();
});
</script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<div class="content" id="Content">
........
答案 1 :(得分:3)
你已经有一个头部:
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<script type="text/javascript" src="Scripts/ZeroClipboard.js"></script>
<script type="text/javascript" src="Scripts/main.js"></script>
</asp:Content>
检查项目中的文件,将内容放入此PlaceHolder。如果要定义<head>
将其包装在此内容占位符周围。但是,您需要检查其他文件的内容并重构它,因此您不会在head
标记内定义head
标记。
<!DOCTYPE html>
<html>
<head runat="server">
<title></title>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<script type="text/javascript" src="Scripts/ZeroClipboard.js"></script>
<script type="text/javascript" src="Scripts/main.js"></script>
</asp:Content>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<div class="content" id="Content">
// ...
</div>
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
答案 2 :(得分:1)
您可以将<head runat="server"></head>
置于内容之上..
答案 3 :(得分:0)
你应该放在另一个文件中吗?
一个是使用母版页文件而另一个不是。