简体   繁体   English

Web服务未执行

[英]Web service doesn't execute

I am trying to use web services, when the user clicks on a button or changes the text of a textbox, a message should be displayed on the screen. 我正在尝试使用Web服务,当用户单击按钮或更改文本框的文本时,应该在屏幕上显示一条消息。

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 服务/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. 在文本框中设置AutoPostBack =“ true”。

HTH. HTH。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM