【发布时间】:2011-10-12 11:53:33
【问题描述】:
我正在尝试在页面完成加载时自动使用我的数据库中的项目填充我的无序列表 () 之一。我需要知道的是如何获得这些物品。我不认为 Controller 和 PartialView 有什么问题。我所需要的只是如何从索引页面调用它。
以下代码来自索引页面:
<div class="contentRight">
<span class="contentRightHeader">Most Followed Questions ·</span><span class="contentRightViewAll"> View all</span>
<ul>
<!--<li>Why do we drink and whats the effects on the body</li>
<li>Why do we drink and whats the effects on the body</li>-->
</ul>
</div>
此代码来自控制器:
public PartialViewResult _ListMostFollowedQuestions()
{
QuestionManager qman = new QuestionManager();
ViewBag.Questions = qman.ListMostFollowedQuestions(3);
return PartialView("_ListMostFollowedQuestions");
}
最后来自我的部分视图:
@foreach (var item in ViewBag.Questions)
{
@item.Topic Deadline:
@item.Deadline
}
感谢您的帮助!
【问题讨论】:
-
在加载
index页面后尝试使用Ajax加载您的列表
标签: jquery ajax asp.net-mvc model-view-controller partial-views