欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

BaiduTemplate模板引擎使用示例(附源碼)

 更新時間:2016年12月22日 16:29:02   作者:Chevin  
本文主要分享了BaiduTemplate模板引擎使用示例,具有很好的參考價值,需要的朋友一起來看下吧

1、新建項目,asp.net 空Web應用程序

添加data,js,styles,templates文件夾,添加baiduTemplate.js,jquery.js,bootstrap.css

2、添加list.js腳本,代碼如下

var data = {
 "list": [
 {
 "col1": "行1",
 "col2": "數(shù)據(jù)2",
 "col3": "數(shù)據(jù)3",
 "col4": "數(shù)據(jù)6",
 "col5": "數(shù)據(jù)5",
 "col6": "數(shù)據(jù)6"
 },
 {
 "col1": "行2",
 "col2": "數(shù)據(jù)2",
 "col3": "數(shù)據(jù)3",
 "col4": "數(shù)據(jù)6",
 "col5": "數(shù)據(jù)5",
 "col6": "數(shù)據(jù)6"
 },
 {
 "col1": "行3",
 "col2": "數(shù)據(jù)2",
 "col3": "數(shù)據(jù)3",
 "col4": "數(shù)據(jù)6",
 "col5": "數(shù)據(jù)5",
 "col6": "數(shù)據(jù)6"
 },
 {
 "col1": "行4",
 "col2": "數(shù)據(jù)2",
 "col3": "數(shù)據(jù)3",
 "col4": "數(shù)據(jù)6",
 "col5": "數(shù)據(jù)5",
 "col6": "數(shù)據(jù)6"
 },
 {
 "col1": "行5",
 "col2": "數(shù)據(jù)2",
 "col3": "數(shù)據(jù)3",
 "col4": "數(shù)據(jù)6",
 "col5": "數(shù)據(jù)5",
 "col6": "數(shù)據(jù)6"
 },
 {
 "col1": "行6",
 "col2": "數(shù)據(jù)2",
 "col3": "數(shù)據(jù)3",
 "col4": "數(shù)據(jù)6",
 "col5": "數(shù)據(jù)5",
 "col6": "數(shù)據(jù)6"
 },
 {
 "col1": "行7",
 "col2": "數(shù)據(jù)2",
 "col3": "數(shù)據(jù)3",
 "col4": "數(shù)據(jù)6",
 "col5": "數(shù)據(jù)5",
 "col6": "數(shù)據(jù)6"
 },
 {
 "col1": "行8",
 "col2": "數(shù)據(jù)2",
 "col3": "數(shù)據(jù)3",
 "col4": "數(shù)據(jù)6",
 "col5": "數(shù)據(jù)5",
 "col6": "數(shù)據(jù)6"
 }
 ]
};
var template = "templates/list.html";
$.ajax({
 url: template,
 dataType: "html",
 success: function (val) {
 $("#list").html(baidu.template(val, data));
 }
});

添加模板文件list.html,內容如下

<table class="table table-bordered">
 <thead>
 <tr>
 <td>列1</td>
 <td>列2</td>
 <td>列3</td>
 <td>列4</td>
 <td>列5</td>
 <td>列6</td>
 </tr>
 </thead>
 <%for(var i = 0; i<list.length;i++){ var item=list[i];%>
 <tr>
 <td><%=item.col1%></td>
 <td><%=item.col2%></td>
 <td><%=item.col3%></td>
 <td><%=item.col4%></td>
 <td><%=item.col5%></td>
 <td><%=item.col6%></td>
 </tr>
 <%}%>
</table>

3、添加default.aspx頁面,并添加引用

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="baiduTemplate.Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
 <title></title>
 <script src="js/jquery.min.js"></script>
 <script src="js/baiduTemplate.js"></script>
 <script src="js/list.js"></script>
 <link href="styles/bootstrap.css" rel="stylesheet" />
</head>
<body>
 <form id="form1" runat="server">
 <div id="list" style="margin-top:10px;">
 </div>
 </form>
</body>
</html>

預覽效果:

源碼下載http://xiazai.jb51.net/201612/yuanma/baiduTemplate_jb51.rar

以上就是本文的全部內容,希望本文的內容對大家的學習或者工作能帶來一定的幫助,同時也希望多多支持腳本之家!

相關文章

  • ASP.NET MVC5網站開發(fā)我的咨詢列表及添加咨詢(十二)

    ASP.NET MVC5網站開發(fā)我的咨詢列表及添加咨詢(十二)

    這篇文章主要為大家詳細介紹了ASP.NET MVC5網站開發(fā)我的咨詢列表及添加咨詢,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2015-09-09
  • ASP.net 路徑問題 詳解

    ASP.net 路徑問題 詳解

    各位有沒有碰到在日常工作中經常在路徑設置的時候把 "~/ 、./ 、../ 、 / 、"這些符號搞混搞亂了?
    2010-05-05
  • .Net WebApi消息攔截器之MessageHandler的示例

    .Net WebApi消息攔截器之MessageHandler的示例

    這篇文章主要介紹了.Net WebApi消息攔截器之MessageHandler的示例,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-08-08
  • asp.net(c#) ubb處理類

    asp.net(c#) ubb處理類

    asp.net下對于編輯器中的ubb進行替換處理的實現(xiàn)代碼
    2008-08-08
  • 如何使用Python實現(xiàn)阿拉伯數(shù)字轉換成中國漢字

    如何使用Python實現(xiàn)阿拉伯數(shù)字轉換成中國漢字

    本文提供了一個Python代碼示例,用于將阿拉伯數(shù)字轉換為中文漢字表示,代碼定義了數(shù)字到漢字的映射表,并實現(xiàn)了處理不同位數(shù)(如個、十、百、千、萬等)的函數(shù),特別地,處理方式包括對大數(shù)字的分解和轉換,以及對連續(xù)零的特殊處理,感興趣的朋友跟隨小編一起看看吧
    2024-09-09
  • 聊一聊Asp.net過濾器Filter那一些事

    聊一聊Asp.net過濾器Filter那一些事

    這篇文章主要介紹了聊一聊Asp.net過濾器Filter那一些事,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2020-06-06
  • .Net獲取IP地址的方法

    .Net獲取IP地址的方法

    這篇文章主要介紹了.Net獲取IP地址的方法,本文給大家介紹的非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-01-01
  • AspNetPager與Socut.Data使用實例代碼

    AspNetPager與Socut.Data使用實例代碼

    最近對AspNetPager與Socut.Data這兩個控件產生了濃厚的興趣,這兩個控件配合可以減輕很多程序員編寫代碼的壓力。ASpNetPager為分頁控件,而Socut.Data為數(shù)據(jù)操作控件,ACCESS,MSSQL都可以。
    2008-07-07
  • VS2010制作第一個簡單網站

    VS2010制作第一個簡單網站

    這篇文章主要為大家介紹VS2010如何制作第一個簡單網站,和大家一起學習 動態(tài)網站開發(fā)技術,感興趣的小伙伴們可以參考一下
    2015-11-11
  • 在.NET中使用Newtonsoft.Json轉換,讀取,寫入的方法介紹

    在.NET中使用Newtonsoft.Json轉換,讀取,寫入的方法介紹

    Newtonsoft.Json.JsonConvert類是非微軟提供的一個JSON序列化和反序列的開源免費的類庫
    2012-08-08

最新評論