今天在项目中要用到简单的MessageBox的使用。在Ext.net中没有Winform那么简单,直接写MessageBox.show()的方法。于是就去examples.ext.net的例子网站找,想找到个实际能用的。 地址:
<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat=
"server">
[DirectMethod]
public void DoConfirm()
{
X.Msg.Confirm("Message", "Confirm?", new MessageBoxButtonsConfig
{
Yes = new MessageBoxButtonConfig
{
Handler = "CompanyX.DoYes()",
Text = "Yes Please"
},
No = new MessageBoxButtonConfig
{
Handler = "CompanyX.DoNo()",
Text = "No Thanks"
}
}).Show();
}
[DirectMethod]
public void DoYes()
{
this.Label1.Text = "YES";
}
[DirectMethod]
public void DoNo()
{
this.Label1.Text = "NO";
}
script>
<!DOCTYPE html
>
<html>
<head runat=
"server">
<title>Confirm MessageBox with ButtonsConfig - Ext.NET Examples
title>
<link href=
"/resources/css/examples.css" rel=
"stylesheet" type=
"text/css" />
head>
<body>
<ext:
ResourceManager runat=
"server" DirectMethodNamespace="CompanyX" />
<form runat=
"server">
<p>
<ext:
Button runat=
"server" Text=
"Confirm" Icon=
"Error">
<Listeners>
<Click Handler=
"CompanyX.DoConfirm()" />
Listeners>
ext:
Button>
p>
form>
body>
html>
其实,可以直接在按钮中写,作用是在执行后台Confirm事件的时候,先弹出MessageBox框,上面两个按钮,是和否。如果选是,才执行后台事件,否则就不会跳转到后台。这个方法很好的解决了简单的提示框功能。
protected void Confirm(
object sender, DirectEventArgs e)
{
X.Msg.Alert(
"点击提示",
"您点击了确定,执行的是后台事件!").Show();
}