[AjaxPro.AjaxMethod]
public void societypaging()
{
PagedDataSource ps = new PagedDataSource();
OleDbConnection myconn = new OleDbConnection(@"provider=microsoft.jet.oledb.4.0;data source=|datadirectory|\news.mdb");
myconn.Open();
OleDbDataAdapter myAdapter = new OleDbDataAdapter("select top 8 * from society order by datatime desc", myconn);
DataSet myDataset = new DataSet();
myAdapter.Fill(myDataset, "society");
ps.DataSource = myDataset.Tables[0].DefaultView;
ps.AllowPaging = true;
ps.PageSize = 8;
DataList1.DataSource = ps;
DataList1.DataKeyField = "id";
DataList1.DataBind();
}
怎么在JS中调用执行这个方法,让它更新datalist中的数据,在线等,求指点
public void societypaging()
{
PagedDataSource ps = new PagedDataSource();
OleDbConnection myconn = new OleDbConnection(@"provider=microsoft.jet.oledb.4.0;data source=|datadirectory|\news.mdb");
myconn.Open();
OleDbDataAdapter myAdapter = new OleDbDataAdapter("select top 8 * from society order by datatime desc", myconn);
DataSet myDataset = new DataSet();
myAdapter.Fill(myDataset, "society");
ps.DataSource = myDataset.Tables[0].DefaultView;
ps.AllowPaging = true;
ps.PageSize = 8;
DataList1.DataSource = ps;
DataList1.DataKeyField = "id";
DataList1.DataBind();
}
怎么在JS中调用执行这个方法,让它更新datalist中的数据,在线等,求指点
用JSON交换数据
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;namespace WebApplication1
{
/// <summary>
/// Summary description for WebService1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class WebService1 : System.Web.Services.WebService
{ [WebMethod]
public string HelloWorld()
{
return "Hello World";
}
}
}
CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %><asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<input type="button" value="Test" onclick="sayHello();" /> <asp:ScriptManager ID="scriptManager1" runat="server" EnablePageMethods="true">
<Services>
<asp:ServiceReference Path="~/WebService1.asmx" />
</Services>
</asp:ScriptManager> <script type="text/javascript">
function sayHello() {
WebApplication1.WebService1.HelloWorld(show);
} function show(word) {
alert(word);
}
</script>
http://www.cnblogs.com/huangxue/archive/2011/12/12/2284981.html
http://www.cnblogs.com/jackyzhou/archive/2009/04/29/1445870.html
function aa() {
var vCaller = '<%=societypaging() %>';
// alert(vCaller);
} </script>
我把这段代码放在head标签之件,页面加载的时候就执行对datalist的操作,放在外部JS文件中,想通过事件来触发,却不行了,求解.:(