首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

js调用cs函数时报错,Microsoft JScript 运行时异常: 缺少对象

2012-11-05 
js调用cs函数时报错,Microsoft JScript 运行时错误: 缺少对象aspx文件C# code%@ Page LanguageC# Auto

js调用cs函数时报错,Microsoft JScript 运行时错误: 缺少对象
aspx文件

C# code
<%@ 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 addmarkers() {            alert("add markers");                        LoadData();                }            </script></head><body>    <div id="toolbar" width="100%; height:20px;" style="text-align: center">        <input type="button" value="mark" onclick="addmarkers()"></input>    </div></body></html>

cs文件
C# code
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);        }    }

求解!先谢谢大家了!

[解决办法]
LZ先学一下Ajax吧
[解决办法]
lz这种写法,很符合调用AjaxPro.2.dll之后写的代码,但lz可能不知AjaxPro.2.dll是什么
[解决办法]
C# code
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);        }    } 

热点排行