日期:2014-05-18 浏览次数:20477 次
@if (Model.IsComment == true) { <div id="ajaxcomment"> @{Html.RenderAction("AddComment", "Comment", new { ArticleID = Model.ArticleID });} </div> } else { <div class="gfx_comment"><a id="comment"></a> <div class="gfx_comment_ul1"><p class="blink b">该评论己关闭</p></div> </div> }
@model IEnumerable<Blog.Models.Comment> @{ var comlist = ViewBag.Comment; } <h2> @Ajax.ActionLink("添加评论", "CreateComment", new { articleid = ViewBag.articleid }, new AjaxOptions { UpdateTargetId = "AddComments" }) </h2> <div id="AddComments"></div>
@model Blog.Models.Comment @{ ViewBag.Title = "CreateComment"; } <script src="@Url.Content("~/Template/Js/jquery.validate.min.js")" type="text/javascript"></script> <script src="@Url.Content("~/Template/Js/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script> <script type="text/javascript"> function ReloadComments() { $("#ajaxcomment").load('@Url.Content("~/Comment/AddComment?articleid="+ ViewBag.articleid)'); } </script> @using (Ajax.BeginForm(new AjaxOptions { OnComplete = "ReloadComments" })) { @Html.Hidden("articleid", (int)ViewBag.articleid); @Html.ValidationSummary(true) <fieldset> <div class="editor-label"> @Html.LabelFor(model => model.Content) </div> <div class="editor-field"> @*@Html.EditorFor(model => model.Content)*@ <textarea name="Content" id="Content" cols="60" rows="8" class="textarea-comment"></textarea> @Html.ValidationMessageFor(model => model.Content) </div> @if (Session["userid"] == null) { <p>您还没有登陆,请 @Html.ActionLink("登陆","Login","Account") 后再评论。</p> } else { <p><input type="submit" value="提交评论" /></p> } </fieldset> }
#region 添加评论 public ActionResult AddComment(int articleid) { ViewBag.articleid = articleid;