views:

36

answers:

1

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
A: 

Use the this:

ViewData["ID"] = commentID;

and then print it with:

<%= ViewData["ID"]%>
Oskar Kjellin
It's right, but i forgot to say I need to check into the aspx page(!!!) is this ajaxRequest. It's impossible, right?
Grienders
the setting part is in your controller and the other part "<%= ViewData["ID"]%>" is in your aspx page
Oskar Kjellin
For example, please. Show the aspx and controller. I'm not sure it will be work success.
Grienders
please post all the code for your "CommentDetails"view. Is it strongly typed?
Oskar Kjellin