想在asp.net mvc2中开发评论和喜欢的部分 [英] want to develop a comment and like section in asp.net mvc2

查看:89
本文介绍了想在asp.net mvc2中开发评论和喜欢的部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我想使用mvc2开发像Facebook这样的评论部分请帮我解决

Hi i want to develop a comment section like Facebook using mvc2 please help me out

推荐答案

1。使用Ajax作为评论表格。

2.让评论表单的控制器操作接受您希望插入评论的帖子的ID。



您可以使用如下表格:



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:

                        @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>





postId是行动接受的ID。 item.PostId是视图中的Model项。当你使用foreach来显示你的帖子时你可以使用它。



祝你好运。



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.


这篇关于想在asp.net mvc2中开发评论和喜欢的部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆