Asp.net mvc Can';t在razor模板中渲染脚本
我已经创建了我的网站使用复合c1.NETCMS与剃须刀主模板。 但是我无法在主布局中呈现脚本。这是我的razor文件 1.MaserLayout.cshtmlAsp.net mvc Can';t在razor模板中渲染脚本,asp.net-mvc,asp.net-mvc-4,razor,c1-cms,Asp.net Mvc,Asp.net Mvc 4,Razor,C1 Cms,我已经创建了我的网站使用复合c1.NETCMS与剃须刀主模板。 但是我无法在主布局中呈现脚本。这是我的razor文件 1.MaserLayout.cshtml @inherits CompositeC1WebPage @{ string websiteTitle = HomePageNode.Title; } <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" class="no-js
@inherits CompositeC1WebPage
@{
string websiteTitle = HomePageNode.Title;
}
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" class="no-js" lang="@Lang">
<head>
<title>@CurrentPageNode.Title</title>
@if (!string.IsNullOrEmpty(CurrentPageNode.Description))
{
<meta name="description" content="@CurrentPageNode.Description" />
}
@PageTemplateFeature("Descriptive HTML head elements")
</head>
<body>
<div class="container-fluid main-container">
@* renders the sub template: *@
@RenderBody()
</div>
</body>
</html>
@继承CompositeC1网页
@{
字符串websiteTitle=HomePageNode.Title;
}
@CurrentPageNode.Title
@如果(!string.IsNullOrEmpty(CurrentPageNode.Description))
{
}
@PageTemplateFeature(“描述性HTML头元素”)
@*呈现子模板:*@
@RenderBody()
上面是我的主模板,这里是我的主模板
@inherits RazorPageTemplate
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
@*you can add template specific head elements here*@
</head>
<body class="frontpage">
<div>Test template</div>
<script>
$(document).ready(function () {
$('.test').click(function () {
alert("test");
})
});
</script>
</body>
</html>
@继承RazorPageTemplate
@*您可以在此处添加特定于模板的头元素*@
测试模板
$(文档).ready(函数(){
$('.test')。单击(函数(){
警报(“测试”);
})
});
但是我无法在masterpage.Cn中运行脚本。请任何人帮助
提前感谢您的帮助。如果Composit-c1使用了一些特殊的剃须刀功能/流,而不是默认值,请忽略此评论
我认为它与composit-c1 razor无关,您应该在主页中定义布局以使用母版页此外,母版页中未定义任何脚本
在派生页面中,您没有创建完整的DOM结构(html、head和body等标记)您是否在主布局中包含了jquery库?bcoz我看不到它我看不到您在模板或函数中任何时候都包含jQuery?