zoukankan      html  css  js  c++  java
  • asp.net ajax使用方法一

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    namespace DownloadProxy
    {
        public partial class RenameDownload : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
    
            }
    
            [System.Web.Services.WebMethod]
            //[System.Web.Script.Services.ScriptMethod()]
         //[System.Web.Services.WebMethod(MessageName="getRangRandom")]
        //[System.Web.Script.Services.ScriptMethod(UseHttpGet=true)]
    public static string AjaxTest(string name) { return "Hello," + name + "!" ; } } }
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RenameDownload.aspx.cs" Inherits="DownloadProxy.RenameDownload" %>
    
    <!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 runat="server" EnablePageMethods="true"></asp:scriptmanager>
        <script type="text/javascript">
            PageMethods.set_timeout(5000);
            PageMethods.set_defaultFailedCallback = "OnFailed";
            PageMethods.AjaxTest("knife", OnSucceed);
    
            function OnSucceed(Message) {
                alert(Message);
            }
    
            function OnFailed(ErrorHander) {
                var ErrorMessage = 'Timeout:' + ErrorHander.get_timedOut() + ',Error Message:' + ErrorHander.get_message();
                ErrorMessage = ErrorMessage + ',Exception Type:' + ErrorHander.get_exceptionType() + ',Error Loaction:' + ErrorHander.get_stackTrace();
                alert(ErrorMessage);
            }
        </script>
        </form>
    </body>
    </html>
  • 相关阅读:
    装饰器的写法以及应用环境
    面向对象中super的作用
    os与sys模块的作用与常用方法
    python re模块
    python 冒泡排序,二分法
    正则表达式
    python 高阶内置函数
    python 内置函数
    python 生成器和生成器表达式
    python 函数名的应用(第一类对象),闭包,迭代器
  • 原文地址:https://www.cnblogs.com/nanfei/p/2728897.html
Copyright © 2011-2022 走看看