2011-03-13 3 views
1

Je cette (Index)ASP.NET MVC 3.0 RenderPartial ne semble pas

<%@ 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"); %> 

Mais le lien ne semble pas quand j'exécute seulement "MyTest" est de savoir comment .

Des idées?

+0

Pouvez-vous également clarifier la méthode d'indexation d'un contrôleur (action)? – Mikhail

Répondre

3

Html.ActionLink renvoie un MvcHtmlString. Alors, appelez cette façon afin de l'avoir sortie le code HTML déjà codé:

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

Notez le départ « : » qui écrit le MvcHtmlString à la page et le manque de « ; » à la fin.

Questions connexes