开发者

ASP.NET MVC 3.0 RenderPartial does not appear

开发者 https://www.devze.com 2023-02-16 17:40 出处:网络
I have this (Index) <%@ Page Language=\"C#\" MasterPageFile=\"~/Views/Shared/Site.Master\" Inherits=\"System.Web.Mvc.ViewPage\" %>

I have this (Index)

<%@ 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;vert开发者_如何学Goical-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"); %>

But the link does not appear when I execute only "MyTest" is how.

Any ideas?


Html.ActionLink returns a MvcHtmlString. So call it this way in order to have it output the already encoded HTML:

<%: Html.ActionLink("Home", "Index", "Home") %>

Note the starting ":" which writes the MvcHtmlString to the page and the lack of ";" at the end.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号