• 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>
  • 相关阅读:
    Leetcode888. 公平的糖果棒交换
    Leetcode81. 搜索旋转排序数组 II
    Leetcode80. 删除排序数组中的重复项 II
    Leetcode1631. 最小体力消耗路径
    Leetcode57. 插入区间
    Leetcode724. 寻找数组的中心索引
    Leetcode18. 四数之和
    Leetcode110. 平衡二叉树
    Leetcode1128. 等价多米诺骨牌对的数量
    python 集合和深浅copy
  • 原文地址:https://www.cnblogs.com/nanfei/p/2728897.html
Copyright © 2020-2023  润新知