tags:

views:

52

answers:

1

I am using Ajax.BeginForm to post comment.

How should I update the Comments section area to incorporate this new comment?

I am displaying comments on the page using the typical "foreach(Comment comment in Model.Comments)"

+1  A: 

You probably return something from your Action, right? Make it, for example, a partial-view with the new post in it. You then get the result in a javascript return handler (that can be specified in the AjaxOptions parameter of Ajax.BeginForm(...)) and insert it into the DOM where appropriate. There's an excellent example of how to do this (and a lot of other cool stuff) in this video tutorial by Phil Haack at PDC 2008. (Tip of the day: if you want to learn ASP.NET MVC, it's really worth the time...)

Tomas Lycken