我有这个(索引)
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Home Page
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<table style="width:100%;">
<tr>
<td style="width:250px;vertical-align:top;"><%: Html.Partial("MainMenuEntity") %></td>
<td style="vertical-align:top;">MyTest</td>
</tr>
</table>
</asp:Content>
MainMenuEntity.ascx
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dynamic>" %>
<% Html.ActionLink("Home", "Index", "Home"); %><br />
<% Html.ActionLink("Customer", "Index", "Customer"); %><br />
<% Html.ActionLink("Product", "Index", "Product"); %><br />
<% Html.ActionLink("Estimation", "Index", "Estimation"); %><br />
<% Html.ActionLink("Invoice", "Index", "Invoice"); %>
但是当我只执行“MyTest”时,链接不会出现。
有什么想法吗?
答案 0 :(得分:3)
Html.ActionLink返回一个MvcHtmlString。所以这样称呼是为了让它输出已编码的HTML:
<%: Html.ActionLink("Home", "Index", "Home") %>
注意起始“:”将MvcHtmlString写入页面并且缺少“;”最后。