ASP.NET MVC ajax - data transfer
- by Grienders
How can I get result from action?
I need to show the commentID on the page (aspx) after successes comment insert.
controller
[AcceptVerbs(HttpVerbs.Post )]
public ActionResult ShowArticleByAjax(Guid id, string commentBody)
{
Guid commentID = Comment.InsertComment(id, commentBody);
//How can I tranfer commentID to the aspx page ???
return PartialView("CommentDetails",Article.GetArticleByID(id));
}
ascx
<%using (Ajax.BeginForm("ShowArticleByAjax", new { id = Model.ID },
new AjaxOptions {
HttpMethod = "Post",
UpdateTargetId = "divCommentDetails",
OnSuccess = "successAddComment",
OnFailure = "failureAddComment",
OnBegin = "beginAddComment"
}))
{ %>
<p>
<%=Html.TextArea("commentBody", new { cols = "100%", rows = "10" })%>
</p>
<p>
<input name="submit" type="image" src="../../Content/Images/Design/button_s.gif"
id="submit" />
</p>
<%} %>
aspx
doesn't matter