部分查看和验证

时间:2013-08-06 19:04:28

标签: asp.net asp.net-mvc

我在线尝试了很多解决方案,试图在加载局部视图时让验证工作,但它们似乎都不起作用。

我目前有一些jQuery代码,如下所示:

$(".alert").click(function () {
    $("#add-comics-container").load("/ManageComics/ComicEditor", function () {
        $.validator.unobtrusive.parse("#add-comics-container");
    });
    $("#add-comics-container").fadeIn();
    $(".blackout").css("display", "block");
    return false;
});

我的/ ManageComics / ComicEditor看起来像:

public ActionResult ComicEditor() {
    return PartialView("_ComicEditorPartial");
}

My Partial或多或少看起来像:

@model Comics.Models.LocalComicModel
@Html.BeginForm("Index", "ManageComics", FormMethod.Post, new { enctype = "multipart/form-data", id = "addComicForm", value = "1"}){ 

<div class="add-comics-item">
   <div class="add-comics-left">
      <span class="add-comics-title bold_text">@Html.LabelFor(u => u.Title)</span>
      <div class="add-comics-help">WebComic Title throughout website</div>
      @Html.ValidationMessageFor(u => u.Title)
   </div>
   <div class="add-comics-right">
      @Html.TextBoxFor(u => u.Title)
   </div>
</div>

}

0 个答案:

没有答案