开发者

Web service doesn't execute

开发者 https://www.devze.com 2023-02-19 04:46 出处:网络
I am trying to use web services, when the user clicks开发者_JAVA百科 on a button or changes the text of a textbox, a message should be displayed on the screen.

I am trying to use web services, when the user clicks开发者_JAVA百科 on a button or changes the text of a textbox, a message should be displayed on the screen.

But when I run the code below nothing happen; it means that no alert message displays on the screen.

Any ideas?

TEST.ASPX

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="test.aspx.vb" Inherits="test" %>

<!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>test</title>

</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="True">
            <Services >
                <asp:ServiceReference Path ="~/Services/authenticateUser.asmx" />
            </Services>
        </asp:ScriptManager>
        <asp:TextBox ID="TextBox1" runat="server" onfocus ="Change()" onblur ="Change()"></asp:TextBox>
        <br />
        <br />
        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
         <input type="button" value="Get Array" onclick="Change()" />
         <span id="spanQuote"></span>
    </div>
    <script type="text/javascript">
        function change() {
            authenticateUser.HelloWorld (

            function (names) {
                var result = '';

                for (var i = 0; i < names.length; i++) {
                    result += names[i] + '\n';
                                               }

                alert(result);
                             }
                                        );

                          }

     </script>
    </form>
</body>
</html>

Services/authenticateUser.asmx

<%@ WebService Language="VB" CodeBehind="~/App_Code/authenticateUser.vb" Class="authenticateUser" %>


**App_Code/authenticateUser.vb**

Imports System

Imports System.Collections

Imports System.Collections.Generic

Imports System.Web

Imports System.Web.Services

Imports System.Web.Services.Protocols

Imports System.Web.Script.Services

Imports System.Web.Script.Serialization


<System.Web.Script.Services.ScriptService()> _

<WebService(Namespace:="http://tempuri.org/")> _

<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _

Public Class authenticateUser
    Inherits System.Web.Services.WebService

    <WebMethod()> _
    Public Function HelloWorld() As String
        Return "Hello World"
    End Function

End Class


Set AutoPostBack="true" on the textbox.

HTH.

0

精彩评论

暂无评论...
验证码 换一张
取 消