Anthem.NET 的回调流程图

本文通过一个简单的ASP.NET Button回调示例,详细介绍了客户端和服务器端的回调过程及执行顺序。涉及预回调、取消回调、错误处理及回调后的操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

下面用一个最简单的 anthem:Button 回调作为例子,理清回调过程中执行函数的次序。
代码如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" %>
<%@ Register TagPrefix="anthem" Assembly="Anthem" Namespace="Anthem" %>

<!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>Untitled Page</title>
    
<script type="text/javascript" language="javascript">
    
function Anthem_PreCallBack(){
        alert('Anthem_PreCallBack');
        
if (!confirm('callback?'))
            
return false;
    }
    
    
function btn1_PreCallback(){
        alert('btn1_PreCallback');
        
if (!confirm('callback?'))
            
return false;
    }
    
    
function btn1_CallbackCacelled(){
        alert('btn1_CallbackCacelled');
    }
    
    
function btn1_PostCallback(){
        alert('btn1_PostCallback');
    }
    
    
function Anthem_CallBackCancelled(){
        alert('Anthem_CallBackCancelled');
    }
    
    
function Anthem_Error(result){
        alert(result.error);
    }
    
    
function Anthem_PostCallBack(){
        alert('Anthem_PostCallBack');
    }
    
</script>
</head>
<body>
    
<form id="form1" runat="server">
    
<div>
        
<anthem:Button ID="btn1" runat="server" Text="按钮1" OnClick="btn1_OnClick"
            PreCallBackFunction
="btn1_PreCallback"
            CallBackCancelledFunction
="btn1_CallbackCacelled"
            PostCallBackFunction
="btn1_PostCallback" />
    
</div>
    
</form>
</body>
</html>

后台代码:
protected void btn1_OnClick(object sender, EventArgs e)
{
    Anthem.Manager.AddScriptForClientSideEval(
"alert('script for eval')");
    
throw new Exception("error message");
}


其流程图如下:

anthem_调用流程.jpg
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值