asp.net代码练习 work015 回调技术
发布日期:2021-05-06 21:17:43 浏览次数:10 分类:技术文章

本文共 1552 字,大约阅读时间需要 5 分钟。

webform1.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="work015.WebForm1" %>
回调技术
用户名
密码

webform1.aspx.cs

using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;namespace work015{    public partial class WebForm1 : System.Web.UI.Page, ICallbackEventHandler    {        string result = "";        protected void Page_Load(object sender, EventArgs e)        {            ClientScriptManager csm = Page.ClientScript;            //参数5,true表示异步,false表示同步            string reference = csm.GetCallbackEventReference(this, "args", "Success", "", "Error", false);            string callbackScript = "function CallServerMethod(args,context) {\n" +                reference + ";\n}";            csm.RegisterClientScriptBlock(this.GetType(), "CallServerMethod", callbackScript, true);        }        public void RaiseCallbackEvent(string eventArgs)        {            if (eventArgs.ToLower().IndexOf("admin") != -1)            {                result = string.Format("{0}已被注册", eventArgs);            }            else            {                result = eventArgs + "可以注册";            }        }        public string GetCallbackResult()        {            return result;        }    }}

 

上一篇:asp.net代码练习 work016 fileupload文件上传
下一篇:asp.net代码练习 work014 ClientScript属性

发表评论

最新留言

感谢大佬
[***.8.128.20]2025年03月13日 04时43分01秒