列表首頁Action內容:
public ActionResult HelpList()
{
Entity.Commons.VPredication vp = new Entity.Commons.VPredication();
Entity.Commons.PagingParam pp = new Entity.Commons.PagingParam(1, 10);
Entity.PagedList<Entity.HelpDocument> list = _HelpDocumentServices.GetHelpDocument(vp, pp);
List<Entity.HelpCategory> clist = _HelpDocumentServices.GetAllCatetories();
clist.Insert(0, new Entity.HelpCategory() { HelpCategoryID = "", CategoryName = "選擇類別" });
ViewData["Category"] = clist;
return View(list);
}
列表使用者控制頁Action內容:
public ActionResult PageHelp(int? pi, string title, string cid)
{
Entity.Commons.VPredication vp = new Entity.Commons.VPredication();
Entity.Commons.PagingParam pp = new Entity.Commons.PagingParam(pi ?? 1, 10);
if (!string.IsNullOrEmpty(title))
vp.AddItem("Title", title);
if (!string.IsNullOrEmpty(cid))
vp.AddItem("HelpCategoryID", cid);
Entity.PagedList<Entity.HelpDocument> list = _HelpDocumentServices.GetHelpDocument(vp, pp);
list.AddParameters = new System.Collections.Specialized.NameValueCollection();
list.AddParameters.Add("title", title);
list.AddParameters.Add("cid", cid);
return PartialView("LelpItemList", list);
}
ASPX檔案:
<asp:Content ID="Content3" ContentPlaceHolderID="ScriptContent" runat="server">
<script type="text/javascript">
$(function() {
$('#search_btn').click(function() {
var title = $('#Title').val();
var cid = $('#CategoryList').val();
$.ajax({
type: "POST",
url: "/Help/PageHelp",
data: "pi=1&title=" + title + "&cid=" + cid,
success: function(data) {
$('#helpitem_div').html(data);
}
});
})
})
</script>
<script src="http://www.cnblogs.com/Scripts/js/Help/DelHelp.js" type="text/javascript"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h1>
<span class="action-span1"><a href="/">管理中心</a> - 協助管理 </span>
</h1>
<div>
標題:<input id="Title" type="text" />分類:
<select id="CategoryList" name="CategoryList">
<%foreach (var i in ViewData["Category"] as List<Entity.HelpCategory>)
{
%>
<option value="<%=i.HelpCategoryID %>" style="color: #339; background-color: #eee;">
<%=i.CategoryName%>
</option>
<%
if (i.SubCategoryies != null)
{
foreach (var ii in i.SubCategoryies)
{
%>
<option value="<%=ii.HelpCategoryID %>"> =><%=ii.CategoryName%>
</option>
<%}
}
} %>
</select>
<input id="search_btn" class="button" type="button" value="查詢" /></div>
<div id="helpitem_div">
<%Html.RenderPartial("LelpItemList", Model); %>
</div>
</asp:Content>
ASCX檔案內容:
<script type="text/javascript">
//連結始終在一個視窗中開啟
function ActiveWin(url) {
var w = screen.availWidth;
var h = screen.availHeight;
var popup = window.open(url, "win_name", "top=0 left=0 scrollbars=yes status=no menubar=0 toolbar=0 resizable=yes");
popup.focus();
return false;
}
</script>
<script src="http://www.cnblogs.com/Scripts/js/liebiao_table.js" type="text/javascript"></script>
<table width="100%" id="" cellpadding="3" cellspacing="1" class="liebiao_table">
<thead>
<tr>
<th>
標題
</th>
<th>
分類
</th>
<th>
排序
</th>
<th>
建立時間
</th>
<th>
操作
</th>
</tr>
</thead>
<tbody>
<%foreach (var item in Model)
{
%>
<tr>
<td>
<a href="/help/HelpDetail?helpid=<%=item.HelpDocumentID %>">
<%=item.Title %></a>
</td>
<td>
<%=item.HelpCategory.FatherCategory.CategoryName %>=><%=item.HelpCategory.CategoryName %>
</td>
<td align="center">
<%=item.SortNumber %>
</td>
<td align="center">
<%=item.CreateDate %>
</td>
<td align="center">
<a href="javascript:void(0)" onclick="ActiveWin('/help/HelpDetail?helpid=<%=item.HelpDocumentID %>')">
查看</a> <a href="javascript:void(0)" onclick="ActiveWin('/Help/EditHelp?hid=<%=item.HelpDocumentID %>')">編輯</a>  <a
href="javascript:void(0)" onclick="DelHtml('<%=Model.PageIndex %>','<%=item.HelpDocumentID %>')">刪除</a>
</td>
</tr>
<%
}
%>
</tbody>
</table>
<%=Html.AjaxPager(Model, "helpitem_div", "PageHelp", "Help")%>