
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; } }}
发表评论
最新留言
感谢大佬
[***.8.128.20]2025年03月13日 04时43分01秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
idea连接服务器远程调试(Dockerfile版)
2019-03-03
ElasicJob分布式定时任务
2019-03-03
feign调用上传文件接口(MultipartFile)
2019-03-03
centos 文件格式不对执行报错 || centos查看或者修改文件格式
2019-03-03
win锁屏界面用户名修改
2019-03-03
Java设计模式 —— 桥接模式(Bridge)
2019-03-03
计算机三级 信息安全技术历年真题(二)总共十套 3月底之前更完
2019-03-03
计算机三级 信息安全技术历年真题(四)总共十套 3月底之前更完
2019-03-03
详解: 最小生成树
2019-03-03
[编程题]:n头牛中选择满足所有m种特性的牛(百度2021)
2019-03-03
Redis中的删除策略和逐出算法
2019-03-03
Redis的持久化策略RDB和AOF
2019-03-03
[数据结构]:红黑树(二)
2019-03-03
Ubuntu切换到root用户无法找到环境变量PATH的问题
2019-03-03
Python基础(二)
2019-03-03
PyCharm安装与配置
2019-03-03
[ERROR]: gitstatus failed to initialize.
2019-03-03
关于Java的List的笔记
2019-03-03
Docker - 部署 Redis 6.0.8
2019-03-03