I need to load all of comments after click button "all comments" without reload page. I have "News" page with comments, after load page we can see one comment below the text news. All data situated in table rows. I have two rows. One row have button "All comments", second row have textbox from comments and button "Add new comment". I need after click button "All comments" load all list comments (dynamic load rows with data) without reload page. And I need to add comment in database after click button "Add new comment" without reload page too. I don't know how to do this.
I have combined model:
using System.Collections.Generic;
namespace NarkomApp.Models
{
public class News_CommentsModel
{
public NEWS newsModel { get; set; }
public List<COMMENTS> commentsModel { get; set; }
public List<NEWS> recomendNewsModel { get; set; }
public List<NEWS> waterShutOffModel { get; set; }
}
}
Code view:
<tr class="trDiscussion">
<td colspan="2">
<div class="gray"></div>
<div class="interesting">
<p>Обсуждение</p>
</div>
</td>
</tr>
<tr class="trComments">
<td width="100%" height="auto" colspan="2">
<div class="comments">
@{
if (Model.commentsModel.Count != 0)
{
for (int i = 0; i < Model.commentsModel.Count; i++)
{
<p>@Model.commentsModel[i].sUserName</p>
<p><a class="date-comment">@Model.commentsModel[i].vDateTime</a></p>
<p class="text-comment">@Model.commentsModel[i].vComment</p>
}
}
else
{
<p>Комментариев нет</p>
}
}
</div>
</td>
</tr>
<tr class="trButtonShowAllComments">
<td colspan="2" height="50px">
<div>
<a class="comm" role="button" href="#">Все комментарии</a>
</div>
</td>
</tr>
<tr class="trAddNewComment">
<td width="100%" height="auto" colspan="2">
@{
if (Session["iIdUsers"] == null)
{
<div class="new-comment">
Вы не авторизированы, для того, чтобы оставлять коментарии войдите под своим аккаунтом: @Html.ActionLink("Войти", "LogIn", "Home")
</div>
}
else
{
<div class="new-comment">
<p>Новый комментарий:</p>
</div>
<textarea class="message" size="40" name="search" placeholder=""></textarea>
<div>
<a class="send" role="button" href="#">Отправить</a>
</div>
}
}
</td>