aspx文件
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="showpage.aspx.cs" Inherits="showpage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
      <script type="text/javascript">             function adders() {
            alert("add ers");
                        LoadData();
                }        
    </script>
</head>
<body>
    <div id="toolbar" width="100%; height:20px;" style="text-align: center">
        <input type="button" value="" onclick="adders()"></input>
    </div>
</body>
</html>
cs文件
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
    public partial class showpage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {        }
       public void  LoadData()
        {
            string sql = "select [Lat],[Lng],[strong] from [dbo].[Test_LatLng]";
            DataTable dt = database.Query(sql);        }    }求解!先谢谢大家了!

解决方案 »

  1.   

    lz这种写法,很符合调用AjaxPro.2.dll之后写的代码,但lz可能不知AjaxPro.2.dll是什么
      

  2.   

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data;
    using AjaxPro;
        public partial class showpage : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
      AjaxPro.Utility.RegisterTypeForAjax(typeof(this));//注册ajax服务   
            }
     [AjaxMethod]
           public DataTable LoadData()
            {
                string sql = "select [Lat],[Lng],[strong] from [dbo].[Test_LatLng]";
                DataTable dt = database.Query(sql);        }    } function adders() {
                alert("add ers");
                         var tb=   showpage.LoadData();
                    }    
    加上AjaxPro.2.dll的引用
      

  3.   

    还是不对呀,Microsoft JScript 运行时错误: 'showpage' 未定义
      

  4.   

    对了,我把 AjaxPro.Utility.RegisterTypeForAjax(typeof(this));//注册ajax服务   
    改成了 AjaxPro.Utility.RegisterTypeForAjax(typeof(showpage));//注册