<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %>
<!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 οnlοad="ck();">
<form id="form1" runat="server">
<div>
<Services>
<asp:ServiceReference Path="~/Default2.asmx" />
</Services>
<input id="Text1" type="text" />
</div>
</form>
</body>
<script language="javascript">
function ck() {
Default2.HelloWorld("hh",back);
}
function back(result) {
document.getElementById("Text1").value = result;
}
</script>
</html>
-----------------------------------------------------------
--------------------------------------------------------------VB代码----------------------------------------------
Imports System.Web.Services
Imports System.Net
Imports System.IO
Imports System.Text.Encoding
'若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
<System.Web.Script.Services.ScriptService()> _
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Default2
Inherits System.Web.UI.Page
<WebMethod()> _
Public Shared Function HelloWorld(ByVal aa As String) As String
If aa = "hh" Then
Return "Hellosdfsdf 新的"
Else
Return "Hellosdfsdf World"
End If
End Function
End Class