gpt4 book ai didi

ASP.NET 母版页 : how to insert markup in the head section inside the aspx?

转载 作者:行者123 更新时间:2023-12-04 09:03:11 25 4
gpt4 key购买 nike

我知道我可以 access the head section of a page which uses a masterpage programmatically这样(在后面的代码中):

这只是一个例子(我想插入脚本和样式等):

this.Header.Title = "I just set the page's title";

是否有一种简单的方法可以在 中执行此操作?声明式 路上 在 aspx 文件本身中 ?

有时插入 会很方便客户端脚本风格宣言或外部资源的链接。

最佳答案

您可以通过使用 head 中的内容区域来做到这一点。 ,与您在 body 中使用的方式完全相同页面的。例如,在您的主页中:

<head>
<link type="text/css" rel="stylesheet" href="/styles/common1.css" />
<script type="text/javascript" src="/scripts/common1.js"></script>
<asp:contentplaceholder id="ExtraStylesAndScripts" runat="server" />
</head>

然后在页面本身就像这样:
<asp:content contentplaceholderid="ExtraStylesAndScripts" runat="server">    
<link type="text/css" rel="stylesheet" href="/styles/extra1.css" />
<link type="text/css" rel="stylesheet" href="/styles/extra2.css" />
<script type="text/javascript" src="/scripts/extra1.js"></script>
<script type="text/javascript" src="/scripts/extra2.js"></script>
</asp:content>

关于ASP.NET 母版页 : how to insert markup in the head section inside the aspx?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/568717/

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