private Dictionary<bool, Action> dic;
protected void Page_Load(object sender, EventArgs e)
{
string value = Request.Form["hName"] ?? ""; bool result; if (bool.TryParse(value, out result))
{
dic = new Dictionary<bool, Action>(); dic.Add(true, Confirm);
dic.Add(false, Cancel); dic[result]();
}
} protected void btnCallBack_Click(object sender, EventArgs e)
{
// 先执行一段代码
lit.Text = DateTime.Now.ToString("yyyy-MM-dd");
//弹出confirm ClientScript.RegisterStartupScript(GetType(), "confirm", "CustomSubmit();", true);
} //确认时执行的代码
private void Confirm()
{
lit.Text = "确认";
} //取消时执行的代码
private void Cancel()
{
lit.Text = "取消";
}
这是非哥博客中对于confirm的改写,Dictionary<bool, Action> dic中ACTION是什么类型,还有我调试的时候if (bool.TryParse(value, out result))中的代码一直没有运行过,这段代码有什么作用
protected void Page_Load(object sender, EventArgs e)
{
string value = Request.Form["hName"] ?? ""; bool result; if (bool.TryParse(value, out result))
{
dic = new Dictionary<bool, Action>(); dic.Add(true, Confirm);
dic.Add(false, Cancel); dic[result]();
}
} protected void btnCallBack_Click(object sender, EventArgs e)
{
// 先执行一段代码
lit.Text = DateTime.Now.ToString("yyyy-MM-dd");
//弹出confirm ClientScript.RegisterStartupScript(GetType(), "confirm", "CustomSubmit();", true);
} //确认时执行的代码
private void Confirm()
{
lit.Text = "确认";
} //取消时执行的代码
private void Cancel()
{
lit.Text = "取消";
}
这是非哥博客中对于confirm的改写,Dictionary<bool, Action> dic中ACTION是什么类型,还有我调试的时候if (bool.TryParse(value, out result))中的代码一直没有运行过,这段代码有什么作用
解决方案 »
- ASP.NET 多线程下载 GLOBAL.asax.cs
- 电子商城的架构??
- 国际化
- IIS问题
- 一个写POWERBUILDE程序的人看到我的表里有主键就对我说,你这是很老的做法...
- 见一用VB写程序中用DataGrid.currentPageIndex=e.NewPageIndex 来指向新页,请问其中的e是什么类?
- 水晶报表 如何根据用户传入的不同的参数 来分组!???
- 北京地区项目外包(金额1万,需要到公司开发,团队人数3个以上)
- .net怎么上传文件到映射盘?能上传到网络共享盘也行啊。
- 就这点分了!高手帮帮忙!关于ASP.NET操作串口通信的问题!急!
- c#网页截图的问题
- jquery更改button的text
if (bool.TryParse(value, out result))
这个表示的是 是否可以将value转换为bool类型,如果可以那么走if里面,result是返回值,就是value转换成bool类型后的值。
Cancel()
从dic = new Dictionary<bool, Action>(); dic.Add(true, Confirm);
dic.Add(false, Cancel);
看出来的@非哥
{
dic = new Dictionary<bool, Action>(); dic.Add(true, Confirm);
dic.Add(false, Cancel); dic[result]();
} 中if里面的代码一直没执行过,dic一直为null,但是最后直接执行了dic[result]();, dic = new Dictionary<bool, Action>();
dic.Add(true, Confirm);
dic.Add(false, Cancel);一直没执行,但是dic突然就有值了,这里一直很纠结。不知道为什么。
dic = new Dictionary<bool, Action>();
dic.Add(true, Confirm);
dic.Add(false, Cancel);这段代码一直没运行,最后却直接运行了dic[result]();,跳过了dic = new Dictionary<bool, Action>();
dic.Add(true, Confirm);
dic.Add(false, Cancel);这段代码,dic突然出现了值,何解。我把地址发出来吧,希望大家能够帮忙看看http://blog.csdn.net/Sandy945/article/details/5716632