資源簡介
在asp.net中使用Jquery,Ajax,Json實(shí)現(xiàn)無刷新分頁

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Linq;
using?System.Web;
using?System.Text;
using?System.Net;
using?System.IO;
using?System.Web.UI;
using?System.Web.UI.WebControls;
public?partial?class?AjaxJson?:?System.Web.UI.Page
{
????public?string?pageCount?=?string.Empty;?//總條目數(shù)
????protected?void?Page_Load(object?sender?EventArgs?e)
????{
????????if?(!IsPostBack)
????????{
????????????string?url?=?“/SupplyAJAX.aspx“;
????????????string?strResult?=?GetRequestJsonString(url?“type=getcount“);
????????????pageCount?=?strResult.ToString();
????????}
????}
????#region?后臺獲取ashx返回的數(shù)據(jù)
????///?
????///?后臺獲取ashx返回的數(shù)據(jù)
????///?
????///?地址
????///?參數(shù)
????///?
????public?static?string?GetRequestJsonString(string?relativePath?string?data)
????{
????????string?requestUrl?=?GetRequestUrl(relativePath?data);
????????try
????????{
????????????WebRequest?request?=?WebRequest.Create(requestUrl);
????????????request.Method?=?“GET“;
????????????StreamReader?jsonStream?=?new?StreamReader(request.GetResponse().GetResponseStream());
????????????string?jsonobject?=?jsonStream.ReadToEnd();
????????????return?jsonobject;
????????}
????????catch
????????{
????????????return?string.Empty;
????????}
????}
????public?static?string?GetRequestUrl(string?relativePath?string?data)
????{
????????string?absolutePath?=?HttpContext.Current.Request.Url.AbsoluteUri;
????????string?hostNameAndPort?=?HttpContext.Current.Request.Url.Authority;
????????string?applicationDir?=?HttpContext.Current.Request.ApplicationPath;
????????StringBuilder?sbRequestUrl?=?new?StringBuilder();
????????sbRequestUrl.Append(absolutePath.Substring(0?absolutePath.IndexOf(hostNameAndPort)));
????????sbRequestUrl.Append(hostNameAndPort);
????????sbRequestUrl.Append(applicationDir);
????????sbRequestUrl.Append(relativePath);
????????if?(!string.IsNullOrEmpty(data))
????????{
????????????sbRequestUrl.Append(“?“);
????????????sbRequestUrl.Append(data);
????????}
????????return?sbRequestUrl.ToString();
????}
????#endregion?
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????3294??2012-12-22?12:21??asp.net+Jquery+Ajax+Json\AjaxJson.aspx
?????文件???????2240??2012-12-22?12:21??asp.net+Jquery+Ajax+Json\AjaxJson.aspx.cs
?????文件??????78601??2010-12-07?09:32??asp.net+Jquery+Ajax+Json\sc
?????文件???????7068??2010-12-28?16:19??asp.net+Jquery+Ajax+Json\sc
?????文件????????665??2012-12-22?09:59??asp.net+Jquery+Ajax+Json\st
?????文件???????1259??2011-01-04?09:59??asp.net+Jquery+Ajax+Json\st
?????文件????????105??2007-09-26?11:47??asp.net+Jquery+Ajax+Json\st
?????文件????????436??2012-12-21?15:18??asp.net+Jquery+Ajax+Json\SupplyAJAX.aspx
?????文件???????4726??2012-12-22?12:20??asp.net+Jquery+Ajax+Json\SupplyAJAX.aspx.cs
?????目錄??????????0??2012-12-22?12:28??asp.net+Jquery+Ajax+Json\sc
?????目錄??????????0??2012-12-22?12:28??asp.net+Jquery+Ajax+Json\st
?????目錄??????????0??2012-12-22?12:27??asp.net+Jquery+Ajax+Json
-----------?---------??----------?-----??----
????????????????98394????????????????????12
評論
共有 條評論