Próbuję skorzystać z rozszerzonego HTML Helper Displayfor w tym widoku:MVC Widok: argumenty typ HTML pomocnika Displayfor nie można wywieść z wykorzystaniem
<%@ 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" />
<% } %>
z następującym 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;
}
}
}
to daje mi ten błąd
argumentów typu dla metody „System.Web.Mvc.Html.Displ ayExtensions.DisplayFor (System.Web.Mvc.HtmlHelper, System.Linq.Expressions.Expression>) ' nie można wywnioskować z użycia. Spróbuj jednoznacznie podać argumenty typu:
Nie mogę określić, co jest nie tak. Zauważ, że jestem w stanie uzyskać dostęp do Modelu w mocno napisany sposób, z IntelliSense pojawiającym się w widoku. Jednak IntelliSense nie pojawia się, kiedy wpisuję wyrażenie lambda.
ja niedawno zorientowali, że poglądy na temat budowy i porządku działaj zgodnie z założeniem, jedyną rzeczą jest to, że nie ma wyskakujących okienek IntelliSense i nieprzyjemnych czerwonych linii/błędów podczas konfigurowania widoku. – Brouwer