当前位置:编程学习 > C#/ASP.NET >>

求大神指点! ASP.NET 在javascript中调用Web服务的函数出现Web服务未定义错误

小弟是刚学的asp.net 在页面中调用Web服务的函数报错!不知道该怎么解决 那位大神知道指点下

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DebugWebForm.aspx.cs" Inherits="googleMap.DebugWebForm" %>

<!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>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
        <Services>
            <asp:ServiceReference  Path="~/GoogleMapWebService.asmx"  InlineScript="true" />
        </Services>
    
    </asp:ScriptManager>
    <div id="GoogleMap_Div" style="width: 500px; height: 500px" >

    </div>
    <div id="directions_canvas">

    </div>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:HiddenField ID="hidEventName" runat="server" />
            <asp:HiddenField ID="hidEventValue" runat="server" />
        </ContentTemplate>
    </asp:UpdatePanel>
    <asp:TextBox ID="TextBox1" runat="server">用于调试</asp:TextBox>
    </form>
    <script src="http://ditu.google.com/maps?file=api&hl=zh-CN&v=2&key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxq-il1QfUnH94QxWIa6N4U6MouMmBA%h1zh=-CN" type="text/javascript"> </script>
<script language="JavaScript" type="text/javascript" >
    var map;
    var trafficInfo = null;
    

    //回调函数
    function fGetGoogleObject(result) 
    {
        document.getElementById('<%=TextBox1.ClientID %>').value = result; //调试 
        //        map.setCenter(new GLatLng(32.060464, 118.796539), 5); //设置中心点
        //    }
        //检查浏览器的兼容性
        if (GBrowserIsCompatible()) 
        {
            //加载地图
            map = new GMap2(document.getElementById("GoogleMap_Div"));
            map.setCenter(new GLatLng(32.060464, 118.796539), 15); //设置中心点
            document.getElementById('<%=TextBox1.ClientID %>').value = "检查浏览器的兼容性"; //调试
                    }

    }
        GoogleMapWebService.fWeb(fGetGoogleObject);
//    PageMethods.fPage(fGetGoogleObject);
</script>
</body>
</html>

Web服务代码如下
[WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
    [System.Web.Script.Services.ScriptService]//存在于System.Web.Extensions.dll中
    public class GoogleMapWebService : System.Web.Services.WebService
    {
        [WebMethod][ScriptMethod]
        public string fWeb()
        {
            return "WebService";
        }
    }

运行到GoogleMapWebService.fWeb(fGetGoogleObject);报错:Microsoft JScript 运行时错误: 'GoogleMapWebService' 未定义
 那位大神给指点迷津啊! web服务 asp.net javascript webservice --------------------编程问答-------------------- 用的是VS2010 --------------------编程问答-------------------- using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;
using KL.cBmap;
using System.Collections.Generic;
using System.Linq;

/// <summary>
///BmapService 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
//若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。 
[System.Web.Script.Services.ScriptService] --------------------编程问答-------------------- $.post("/GoogleMapWebService.asmx/fWeb",{形参1:参数1,形参2:参数2... 没有参数写NULL},function(data){
//要进行的操作

},"text");"text":为返回值类型。
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,