List homepage action content:
PublicActionresult helplist ()
{
Entity. commons. vpredication Vp =NewEntity. commons. vpredication ();
Entity. commons. pagingparam pp =NewEntity. commons. pagingparam (1, 10 );
Entity. pagedlist <entity. helpdocument> List = _ helpdocumentservices. gethelpdocument (VP, pp );
List <entity. helpcategory> clist = _ helpdocumentservices. getallcatetories ();
Clist. insert (0,NewEntity. helpcategory () {helpcategoryid ="", Categoryname ="Select category"});
Viewdata ["Category"] = Clist;
ReturnView (list );
}
Action content on the user control page of the list:
PublicActionresult pagehelp (Int? Pi,StringTitle,StringCID)
{
Entity. commons. vpredication Vp =NewEntity. commons. vpredication ();
Entity. commons. pagingparam pp =NewEntity. 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 =NewSystem. Collections. Specialized. namevaluecollection ();
List. addparameters. Add ("Title", Title );
List. addparameters. Add ("CID", CID );
ReturnPartialview ("Lelpitemlist", List );
}
Aspx file:
<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'Pai.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>
<SpanClass=Action-span1"> <A href ="/"> Management Center </a>-help management </span>
</H1>
<Div>
Title: <input id ="Title"Type ="Text"/> Category:
<Select id ="Categorylist"Name ="Categorylist">
<%Foreach(VAR IInViewdata ["Category"]AsList <entity. helpcategory>)
{
%>
<OptionValue="<% = I. helpcategoryid %>"Style ="Color: #339; Background-color: # Eee ;">
<% = I. categoryname %>
</Option>
<%
If(I. subcategoryies! =Null)
{
Foreach(VAR IIInI. subcategoryies)
{
%>
<OptionValue="<% = II. helpcategoryid %>"> & Nbsp; & nbsp ;=><%= II. categoryname %>
</Option>
<%}
}
} %>
</SELECT>
<Input id ="Search_btn" Class="Button"Type ="Button" Value="Query"/> </Div>
<Div id ="Helpitem_div">
<% Html. renderpartial ("Lelpitemlist", Model); %>
</Div>
</ASP: content>
Ascx file content:
<SCRIPT type ="Text/JavaScript">
// The link is always open in a window
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>
Title
</Th>
<TH>
Category
</Th>
<TH>
Sort
</Th>
<TH>
Creation Time
</Th>
<TH>
Operation
</Th>
</Tr>
</Thead>
<Tbody>
<%Foreach(VAR itemInModel)
{
%>
<Tr>
<TD>
<A href ="/Help/helpdetail? Helpid = <% = item. help0000entid %>">
<% = 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. help0000entid %> ')">
View </a> & nbsp; <a href ="Javascript: void (0 )"Onclick ="Activewin ('/help/edithelp? Hid = <% = item. help0000entid %> ')"> Edit </a> & nbsp; & nbsp <
Href ="Javascript: void (0 )"Onclick ="Delhtml ('<% = model. pageindex %>', '<% = item. help0000entid %> ')"> Delete </a>
</TD>
</Tr>
<%
}
%>
</Tbody>
</Table>
<% = Html. ajaxpager (model,"Helpitem_div","Pagehelp","Help") %>