ASP.NET MVC ajax - data transfer

Posted by Grienders on Stack Overflow See other posts from Stack Overflow or by Grienders
Published on 2010-03-23T19:04:12Z Indexed on 2010/03/23 19:13 UTC
Read the original article Hit count: 582

Filed under:
|

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

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about AJAX