艺海无涯,学无止境。欢迎一起探讨技术和人生,了解我

响应确认对话框的按钮(PageManager的CustomEvent事件)


<body>
<form id="form1" runat="server">
<f:PageManager ID="PageManager1" OnCustomEvent="PageManager1_CustomEvent" runat="server" />
<f:Button Text="操作(点击确定、取消都会回发页面)" runat="server" ID="btnOperation" EnablePostBack="false">
</f:Button>
</form>
</body>


protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
btnOperation.OnClientClick = Confirm.GetShowReference("确认执行操作?",
String.Empty,
MessageBoxIcon.Question,
PageManager1.GetCustomEventReference("Confirm_OK"),
PageManager1.GetCustomEventReference("Confirm_Cancel"));
}
}


protected void PageManager1_CustomEvent(object sender, CustomEventArgs e)
{
if (e.EventArgument == "Confirm_OK")
{
Alert.Show("执行了确定操作!");
}
else if (e.EventArgument == "Confirm_Cancel")
{
Alert.Show("执行了取消操作!");
}
}