Click here to Skip to main content
15,912,205 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi i want to develop a comment section like Facebook using mvc2 please help me out
Posted

1 solution

1. Use an Ajax for for the comment form.
2. Make the controller action for the comment form to accept the Id of the Post your wish to insert the comment for.

You can use a form such as the one below:

C#
                        @using (Ajax.BeginForm("PostComment", "Comment",
                            new { postId = item.PostId },
                            new AjaxOptions
                            {
                                HttpMethod = "GET",
                                InsertionMode = InsertionMode.InsertAfter,
                                UpdateTargetId = "comments-" + item.PostId,
                                OnSuccess = done();"
                            }))
                        { 
                            <textarea name = "message"></textarea>                       
                            <div class="edit-buttons">                    
                                <input type = "submit" class="text-button" value = "Post" />
                        }
</div>


The postId is an Id the Action accepts. The item.PostId is the Model items in your View. You use it when you are using foreach to display your Posts.

Good luck.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900