che sto cercando di fare uso del prolungato Helper HTML DisplayFor in questa Vista:MVC Vista: argomenti di tipo Html DisplayFor aiuto non può essere dedotta dal utilizzo
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MvcCms.Web.ViewModels.SubscriptionsViewModel>" %>
<% using (Html.BeginForm("TrainingSubscription", "Account", FormMethod.Post))
{ %>
<%: Html.DisplayFor(m => m.Subscriptions) %>
<input type="submit" value="Save" />
<% } %>
con il seguente ViewModel
namespace MvcCms.Web.ViewModels
{
public class SubscriptionsViewModel
{
public string TrainingId { get; set; }
public string Subject { get; set; }
public IEnumerable<SubscriptionViewModel> Subscriptions { get; set; }
public SubscriptionsViewModel(string TrainingId, string Subject, IEnumerable<SubscriptionViewModel> Subscriptions)
{
this.TrainingId = TrainingId;
this.Subject = Subject;
this.Subscriptions = Subscriptions;
}
}
public class SubscriptionViewModel
{
public string ContactId { get; set; }
public string FullName { get; set; }
public bool Subscribed { get; set; }
public SubscriptionViewModel(string ContactId, string FullName, bool Subscribed)
{
this.ContactId = ContactId;
this.FullName = FullName;
this.Subscribed = Subscribed;
}
}
}
mi sta dando questo errore
Gli argomenti di tipo per il metodo 'System.Web.Mvc.Html.Displ ayExtensions.DisplayFor (System.Web.Mvc.HtmlHelper, System.Linq.Expressions.Expression>) ' non può essere dedotto dall'utilizzo. Prova a specificare esplicitamente gli argomenti del tipo
Non riesco a capire cosa c'è che non va. Si noti che sono in grado di accedere al modello in modo fortemente tipizzato con IntelliSense che si apre nella vista. Tuttavia, IntelliSense non sta spuntando quando sto digitando l'espressione lambda.
Recentemente ho pensato che le opinioni costruiscono fine e funziona come supposto, l'unica cosa è che non c'è alcun popup IntelliSense e brutte linee rosse/errori quando si imposta la vista .. – Brouwer