2013-08-29 5 views
0

Почему я получаю эту ошибку? Конечно, SelectIssuePriority не существует в моей первой модели. Я добавил.CS1061: не содержит определения для

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS1061: 'Devcore' does not contain a definition for 'SelectIssuePriority' and no extension method 'SelectIssuePriority' accepting a first argument of type 'Devcore.' could be found (are you missing a using directive or an assembly reference?) 

Source Error: 


Line 77: 
Line 78:   <div class="editor-label"> 
Line 79:    <%: Html.LabelFor(model => model.SelectIssuePriority) %> 
Line 80:   </div> 
Line 81:   <div class="editor-field"> 

Модель

namespace Devcore.Models 
{ 
    [MetadataType(typeof(IssueMetaData))] 
    public partial class Issue 
    { 

    } 


    public class IssueMetaData 
    { 
     [Required(ErrorMessage="Summary is required",AllowEmptyStrings = false)] 
     public string Summary { get; set; } 


     [Display(Name = "Priority")] 
     [Required(ErrorMessage = "Priority is required", AllowEmptyStrings = false)] 
     public string SelectIssuePriority { get; set; } 
    } 
} 

Aspx

<div class="editor-label"> 
      <%: Html.LabelFor(model => model.SelectIssuePriority) %> 
     </div> 
     <div class="editor-field"> 
      <%: Html.DropDownList("SelectIssuePriority") %> 
      <%: Html.ValidationMessageFor(model => model.SelectIssuePriority) %> 
     </div> 

ответ

1

IIRC, эти MetaData классы расширения чисто для проверки. Если ваша базовая модель не обладает этими свойствами, это не сработает.

Так что вам нужно это для вида, чтобы признать, что свойства существуют:

[MetadataType(typeof(IssueMetaData))] 
public partial class Issue 
{ 
    public string SelectIssuePriority { get; set; } 
} 

И вам нужно MetaData класса для DataAnnotations для работы с проверкой модели.

+0

Благодарим вас за более быстрый ответчик. Так быстро я не могу закрыть проблему. – AFetter