html.Partial并不能很好地工作,事实上它只显示路径~/Views/Shared/IconMenuPSA.cshtml
,而不是显示HTML内容。
我在哪里做错了?
我在App_Code文件夹中的简单自定义助手:
辅助
@using System.Web.Mvc.Html
@helper DefaultTitle(System.Web.Mvc.HtmlHelper html, string content) {
<br />
<div class="well well-sm text-center text-primary">
html.Partial("~/Views/Shared/IconMenuPSA.cshtml")
<p style="font-size:x-large">@content</p>
</div>
}
查看
@model DatiGeneraliViewModel
@{
ViewBag.Title = "DatiGenerali";
Layout = "~/Views/Shared/_LayoutMainPage.cshtml";
}
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryui")
@Scripts.Render("~/bundles/bootstrap")
@MyHelper.DefaultTitle(Html, "Dati Generali")
PartialView
<div style="float:left">
<!-- Split button -->
<div class="btn-group">
<a href="MainPage" class="btn btn-primary" title="Torna al cruscotto">
<span class="glyphicon glyphicon-tasks"></span>
</a>
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
<li><a href="MainPage">Cruscotto</a></li>
<li role="separator" class="divider"></li>
<li><a href="DatiGenerali">Dati Generali</a></li>
<li role="separator" class="divider"></li>
<li><a href="SezioneRiepilogo">Riepilogo </a></li>
</ul>
</div>
</div>
我该如何解决这个问题? 感谢。