http://weblogs.asp.net/scottgu/archive/2006/10/22/Tip_2F00_Trick_3A00_-Cool-UI-Templating-Technique-to-use-with-ASP.NET-AJAX-for-non_2D00_UpdatePanel-scenarios.aspx

 

using System;
using System.Web.Services;

[Microsoft.Web.Script.Services.ScriptService]
public class SimpleService : WebService {

    [WebMethod]
    public string GetMessage(string name) {
        return "Hello <strong>" + name + "</strong>, the time here is: " + DateTime.Now.ToShortTimeString();
    }
} 

<html>
<head >
    <title>Hello World Service</title>
    <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
    
    <script language="javascript" type="text/javascript">
        
        function callServer() {
            SimpleService.GetMessage( $get("Name").value, displayMessageCallback );
        }
    
        function displayMessageCallback(result) {
            $get("message").innerHTML = result;
        }
    
    </script>
                
</head>
<body>
    <form >
        
        <asp:ScriptManager ID="ScriptManager1" runat="server" >
            <Services>
                <asp:ServiceReference Path="~/SimpleService.asmx" />
            </Services>
        </asp:ScriptManager>
        
        <h1>Hello World Example</h1>
        
        <div>
            Enter Name: <input  />
            
            <a href="BLOCKED SCRIPTcallServer()">Call Server</a>

            <div ></div>
        </div>
        
    </form>
</body>
</html> 
ScriptManager调用WebService.示例

 

相关文章:

  • 2022-12-23
  • 2021-11-13
  • 2021-12-14
  • 2021-09-18
  • 2023-04-10
  • 2022-12-23
  • 2021-07-04
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-22
相关资源
相似解决方案