我想通过信号R获取所有通知,我想填写下拉列表,其中包含来自数据库的所有通知...我收到了所有通知但是当我在下拉列表中显示时...所有都不合适格式..这些都只是一个通知...
控制器===>>>
public ActionResult GetMessages()
{
MessagesRepository _messageRepository = new MessagesRepository();
return PartialView("_MessagesList", _messageRepository.GetAllMessages());
}
查看==>>>
function getAllMessages()
{
var tbl = $('#messagesTable');
$.ajax({
url: '/Home/GetMessages',
contentType: 'application/html ; charset:utf-8',
type: 'GET',
cache:'false',
dataType: 'html'
}).success(function (result) {
$.notiny({
text: 'New Notification Available You May Check',
animation_hide: 'custom-hide-animation 0.5s forwards'
});
tbl.empty().append(result);
}).error(function () {
});
}
答案 0 :(得分:1)
在_Message视图中,您应该在<table>
标记中编写代码......就像这样
_message ==&GT;&GT;
<table>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Message)
@Html.DisplayFor(modelItem => item.EmptyMessage)
</td>
</tr>
}
</table>