Chr*_*Run 5 forms ajax asp.net-mvc
嗨,大家好我有问题,我不明白为什么会发生这种情况.
出于某种原因,我的第二次提交时,我的ajax调用是双重发布.
我有一个包含这个的视图:
@using (Ajax.BeginForm("Create", "BasketPage", new AjaxOptions
{
InsertionMode = InsertionMode.Replace,
UpdateTargetId = "myDiv",
}))
{
<textarea id="comment" name="comment"> </textarea> <br />
<input type="submit" class="btn btn-blue" value="Comment" />
}
Run Code Online (Sandbox Code Playgroud)
调用的BasketPage控制器操作如下所示:
public PartialViewResult Create(BasketPage currentPage, string comment)
{
Comment newComment = new Comment()
{
Username = User.Identity.Name,
Text = HttpUtility.HtmlEncode(comment),
PageID = currentPage.PageLink.ID
};
commentRepository.Save(newComment);
var model = new BasketListModel(currentPage)
{
CommentsList = commentRepository.GetComments(currentPage.PageLink)
};
return PartialView("_Comment", model);
}
Run Code Online (Sandbox Code Playgroud)
问题场景:
如果我用常规的@ Html.BeginForm替换Ajax.beginform,则只调用一次Save方法.
我错过了什么?
| 归档时间: |
|
| 查看次数: |
837 次 |
| 最近记录: |