为了使用CNBLOG上的服务器端ConfirmDialog,我自己做了一个,用起来还不错.

1. 界面:

>


界面可以自己定义,但是必须要有两个Label和两个Button,而且名字必须跟上面的一样.

2. 界面的后台代码:

ConfirmDialognamespace Newtop.Common.Web.UserControls


类中关键是InitDialog方法,他接收一个ConfirmDialogArgs的实例作为参数,用来初始化Dialog.

3. ConfirmDialogArgs类

ConfirmDialogusing System;
ConfirmDialog
using System.Web.UI.WebControls;
ConfirmDialog
ConfirmDialog
namespace Newtop.Common.Web.UserControls
}


这个类比较简单,请对照InitDialog方法理解,这里就不在赘述了.

4. 使用方法
其实使用这个东西很简单,分以下几步:

4.1 建立页面.
把 1 中的用户控件放在一个aspx页面中.

4.2 在aspx文件中为对话框初始化一个ConfirmDialogArgs的实例.
ConfirmDialogprivate void Page_Load(object sender, System.EventArgs e)
        }

因为我的程序中用了UIP,所以,我这里是直接从State中取出了一个ConfirmDialogArgs的实例.

下面我们来看一个初始化ConfirmDialogArgs的例子:

ConfirmDialog        ConfirmDialogArgs args = new ConfirmDialogArgs();
ConfirmDialog        args.Title 
= "Delete";
ConfirmDialog        args.Text 
= "Delete it!";
ConfirmDialog        args.YesCmdHandler 
= new CommandEventHandler(this.DeleteVfSystemCommand);
ConfirmDialog        args.YesCmdArgs 
= e.CommandArgument.ToString();
ConfirmDialog
ConfirmDialog
ConfirmDialog        MyController.State[
"ConfirmDialogArgs"= args;
ConfirmDialog
ConfirmDialog        MyController.PerformConfirm();


最后那一句是转向显示对话框的页面.

上面代码中有一个DeleteVfSystemCommand的方法,用来作为对话框选择了"是"的时候做委托.下面是他的具体代码:

ConfirmDialogprivate void DeleteVfSystemCommand(object sender,CommandEventArgs e)
        }


现在这个对话框一切正常,都还好用.我这里只是提供一个建议,不喜勿怪.

相关文章:

猜你喜欢
  • 2021-07-02
  • 2021-12-12
  • 2022-12-23
相关资源
相似解决方案