0
的定义我目前正在通过MVC音乐商店教程。目前我被困在第53页,我想知道是否有人可以帮助我。MVC错误:'对象'不包含''
我目前收到以下两个错误:
'object' does not contain a definition for 'Artists'
'object' does not contain a definition for 'Genres'
我想我看着它的时间太长了,我不能当场我的错误。一双新鲜的眼睛可以做到这一点!
这里是发生错误的ASPX文件:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MvcMovies1.ViewModels.StoreManagerViewModel>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Edit
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>Edit</h2>
<% using (Html.BeginForm())
{ %>
<%: Html.ValidationSummary(true)%>
<fieldset>
<legend>Edit Album</legend>
<%: Html.EditorFor(model => model.Album,
new object{ Artists = Model.Artists, Genres = Model.Genres }) %>
<p><input type="submit" value="Save" /></p>
</fieldset>
<% } %>
</asp:Content>
这里是一流的,这个网页应该被调用,可以这么说:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MvcMovies1.Models;
namespace MvcMovies1.ViewModels
{
public class StoreManagerViewModel
{
public Album Album { get; set; }
public List<Artist> Artists { get; set; }
public List<Genre> Genres { get; set; }
}
}
PS - 我知道我的一些名字是MvcMovies1,我把它称为错误,但一切都相应引用。
+1 - 这个错误通常是由intellisense引起的,当你在单词“new”后点击空格时,intellisense会粘住单词“object”。唯一已知的解决方法是1)记得删除它,2)输入“new {”,没有空格(当你得到关闭时它会增加空间)“}”。 – Fenton 2010-10-20 14:51:59
谢谢!这是智能感觉好吧我想我正在寻找更复杂的东西!一旦时间到了,我会把它标记为正确的答案! – 109221793 2010-10-20 14:57:36
@索尼,这已经是我一生中很长一段时间的祸根! – DaveDev 2010-10-29 23:35:29