我创建了 _LoginPartial 并在默认 _Layout 中使用它,它工作正常,但是当我创建另一个 _AdminLayout 时,我遇到了问题。
我已经在页面顶部添加了
@using System.Web.Mvc
@using System.Web.Mvc.Html
我无法在 _AdminLayout 中添加我的 _LoginPartial 并出现以下错误
“System.Web.WebPages.Html.HtmlHelper'不包含'Partial'的定义和最佳扩展方法重载'System.Web.Mvc.Html.PartialExtensions.Partial(System.Web.Mvc.HtmlHelper, string)'有一些无效的论点“
我的代码是
@using System.Web.Mvc
@using System.Web.Mvc.Html
<!DOCTYPE html>
<html lang="en">
<head>
@*<title>@ViewBag.Title</title>
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery-1.4.4.min.js")"
type="text/javascript"></script>*@
<style type="text/css">
/*Initialize*/ul#menu, ul#menu ul.sub-menu
{
padding: 0;
margin: 0;
}
ul#menu li, ul#menu ul.sub-menu li
{
list-style-type: none;
display: inline-block;
}
/*Link
Appearance*/ul#menu li a, ul#menu li ul.sub-menu li a
{
text-decoration: none;
color: #fff;
background: #666;
padding: 5px;
display: inline-block;
}
/*Make the
parent of sub-menu relative*/ul#menu li
{
position: relative;
}
/*sub menu*/ul#menu li ul.sub-menu
{
display: none;
position: absolute;
top: 30px;
left: 0;
width: 100px;
}
ul#menu li:hover ul.sub-menu
{
display: block;
}
</style>
</head>
<body>
<div>
<table border="1" width="100%" style="background-color: Lime; margin-top: 30px">
<tr>
<td>
@Html.Partial("_LoginPartial")
</td>
</tr>
<tr>
<td>
<ul id="menu">
</ul>
</li>
<li><a href="#">Manage Product</a>
<ul class="sub-menu">
</ul>
</li>
<li><a href="#">Manage Order</a>
<ul class="sub-menu">
</ul>
</li>
<li><a href="#">Manege user</a>
<ul class="sub-menu">
</ul>
</li>
<li><a href="#">Set NewProduct</a>
<ul class="sub-menu">
</ul>
</li>
<li><a href="#">Set Home Category</a>
<ul class="sub-menu">
</ul>
</li>
<li><a href="#">Category Wise product</a>
<ul class="sub-menu">
</ul>
</li>
<li><a href="#">Feature product</a>
<ul class="sub-menu">
</ul>
</li>
</ul>
</td>
</tr>
<tr>
<td>
@RenderBody()
</td>
</tr>
</table>
</div>
</body>
</html>