我有以下視圖,該視圖無法驗證Title和NewsContent。標題驗證有效,但不是NewsContent。我如何解決它。MVC3驗證問題
@model Foo.NewsViewModel
@{
ViewBag.Title = "Create";
}
@using (Html.BeginForm("Create", "News", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<div>
<fieldset>
<legend>Category Information</legend>
<div class="editor-label">
@Html.LabelFor(m => m.News.Title)
</div>
<div class="editor-field">
@Html.TextBoxFor(m => m.News.Title)
@Html.ValidationMessageFor(m => m.News.Title)
</div>
<div class="editor-label">
@Html.LabelFor(m => m.News.NewsContent)
</div>
<div class="editor-field" id="container">
@Html.TextAreaFor(m => m.News.NewsContent)
@Html.ValidationMessageFor(m => m.News.NewsContent)
</div>
<div class="editor-label">
@Html.LabelFor(m => m.News.Thumbnail)
</div>
<div class="editor-field">
<input type="file" name="files" id="thumbnail" />
</div>
<div class="editor-label">
@Html.LabelFor(m => m.News.Image)
</div>
<div class="editor-field">
<input type="file" name="files" id="original" />
</div>
<div class="editor-label">
@Html.Label("SelectedCategoryId")
</div>
<div class="editor-field">
@Html.DropDownListFor(m => m.SelectedCategoryId, Model.Categories)
</div>
<div class="editor-label">
Publish
</div>
<div class="editor-field">
@Html.CheckBoxFor(m => m.News.Published, new { @checked = "checked" })
</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
</div>
}
這裏是模型|:
public class News : IStorable
{
[Required]
[Display(Name = "Title")]
public virtual string Title { get; set; }
[Required]
[Display(Name = "Content")]
public virtual string NewsContent { set; get; }
......
像FCKEditor的等它只是textarea的現在BT我會添加所見即所得 – 2012-04-18 15:00:03
新聞內容富文本區域? – DarthVader 2012-04-18 15:01:18
實體框架「的味道」你用它 – NSGaga 2012-04-18 15:08:31