I am trying to use the HTML Displayper Extended Helper in this view:
<%@ 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" /> <% } %>
with the following 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; } } }
It gives me this error
Type arguments for the method 'System.Web.Mvc.Html.DisplayExtensions.DisplayFor (System.Web.Mvc.HtmlHelper, System.Linq.Expressions.Expression>)' cannot be taken out of use. Try explicitly specifying type arguments
I canโt understand what happened. Please note that I can access the model in a strongly typed way when IntelliSense appears in the view. However, IntelliSense does not appear when I type a lambda expression.
source share