Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 母版页中定义的js和css不包含在子页中_Asp.net_Master Pages - Fatal编程技术网

Asp.net 母版页中定义的js和css不包含在子页中

Asp.net 母版页中定义的js和css不包含在子页中,asp.net,master-pages,Asp.net,Master Pages,你好: 我是asp.net新手,所以我遇到了一些关于母版页的问题 我定义了一个母版页,并在其中设置了一些css和js: <%@ Master Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"

你好: 我是asp.net新手,所以我遇到了一些关于母版页的问题

我定义了一个母版页,并在其中设置了一些css和js:

<%@ Master Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 
    1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server" >
    <title>Master page title</title>
    <script xx.js></script>
</head>
<body>
    <form id="form1" runat="server">
        <table>
           <tr>
               <td><asp:contentplaceholder id="Main" runat="server" /></td>
               <td><asp:contentplaceholder id="Footer" runat="server" /></td>
           </tr>
        </table>
    </form>
</body>
</html>
然后我的孩子页面:

<% @ Page Language="C#" MasterPageFile="~/Master.master" Title="Content Page 1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Main" Runat="Server">
    Main content.
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="Footer" Runat="Server" >
    Footer content.
</asp:content>
当我启动子页面时,我发现xx.js没有包含在这个页面中,问题是什么

<head>
<script type="text/javascript" src="xx.js"></script>
</head>

这个xx.js应该在您的应用程序中

您是否正确指定了js文件路径,像这样?您可以访问母版页中的xx.js吗?如果您在Visual Studio中工作,您可以将js文件从解决方案资源管理器拖放到母版页的HTML中,它将自动为您创建具有正确路径的脚本标记。是的,我的母版页中的xx.js只是一个示例,它的路径在我的应用程序中是正确的,当我检查html子页面的源代码时,我找不到xx.js,如果路径不正确,它将显示在源html代码中,不是吗?