1, new project, asp.net empty Web application
Add Data,js,styles,templates folder, add Baidutemplate.js,jquery.js,bootstrap.css
2, add List.js script, the code is as follows
Vartemplate = "templates/list.html";
$ ("#list"). HTML (Baidu.template (val, data);
|
Add template file list.html, which reads as follows
<tableclass= "Table table-bordered" >
<%for (var i = 0; i<list.length;i++) {varitem=list[i];%>
|
3, add Default.aspx page, and add Reference
<%@ Page language= "C #" autoeventwireup= "true" codebehind= "Default.aspx.cs" inherits= "Baidutemplate.default"%>
<metahttp-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<scriptsrc= "Js/jquery.min.js" ></script>
<scriptsrc= "Js/baidutemplate.js" ></script>
<scriptsrc= "Js/list.js" ></script>
<linkhref= "Styles/bootstrap.css" rel= "stylesheet"/>
<formid= "Form1" runat= "Server" >
<divid= "List" style= "margin-top:10px;" >
|
Preview Effect: