前言:
本示例大概功能是前臺通過JQuery的呼叫一般處理程式(Handler),獲取表格需要顯示的資訊,然後轉換成json格式返回給前臺,前臺獲取到資料後迴圈構建表格的行,最好把行附加到表裡。
目標:
a 熟悉簡單JQuery Ajax的使用
b 瞭解如何構造基本的Json格式的資料(構建Json也可以通過第三方的dll)
c 熟悉下handler的基本用法
1 簡單效果圖
2 前臺程式碼
<%@ page="" language="C#" autoeventwireup="true" codefile="" inherits="JQueryTest_DialogAjax">
3 Handler程式碼
<%@ webhandler="" language="C#" class="TestHandler">using System;using ;using ric;using ;using DataDAL;using DataEnity;public class TestHandler : IHttpHandler { HttpRequest Request; HttpResponse Response; public void ProcessRequest (HttpContext context) { //不讓瀏覽器快取 er = true; resAbsolute = ays(-1); eader("pragma", "no-cache"); eader("cache-control", ""); eControl = "no-cache"; entType = "text/plain"; Request = est; Response = onse; string method = Request["Method"]ring(); odInfo methodInfo = ype()ethod(method); ke(this, null); } public void GetModuleInfo() { StringBuilder sb = new StringBuilder(); string jsonData = y; List
以上程式碼超簡單吧,JQuery Ajax動態生成Table表格的內容就全部完成了,希望對大家有所幫助。