发布于 2016-06-12 10:18:05 | 156 次阅读 | 评论: 1 | 来源: 网友投递

这里有新鲜出炉的精品教程,程序狗速度看过来!

ASP.NET

ASP.NET 是.NET FrameWork的一部分,是一项微软公司的技术,是一种使嵌入网页中的脚本可由因特网服务器执行的服务器端脚本技术,它可以在通过HTTP请求文档时再在Web服务器上动态创建它们。 指 Active Server Pages(动态服务器页面) ,运行于 IIS(Internet Information Server 服务,是Windows开发的Web服务器)之中的程序 。


aspxgridveiw是devexpress的一个grid控件,使用起来还不错,不能再 CustomButtonCallback 事件中使用response.write,具体的解决方法如下,感兴趣的朋友可以参考下哈
aspxgridveiw是devexpress的一个grid控件,使用起来还不错。但是今天遇到一个问题,就是不能再 CustomButtonCallback 事件中使用response.write,因为CustomButtonCallback 事件是无刷新的,所以不支持,但是即使使用ScriptManager.RegisterClientScriptBlock(page, page.GetType(), "MyScript", myScript, true)也无济于事,在网上查了很久,官方有个解决办法,原文如下:
Hi Troy;
To provide this functionality you should throw an exception in the CustomButtonCallback event handler and process this exception in the CallbackError event handler. Here is the simple sample:
 
protected void ASPxGridView1_CustomButtonCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomButtonCallbackEventArgs e) 
{ 
throw new Exception("Here I am!"); 
} 

 
if (e.message == 'Here I am!') 
{ 
clientErrorImage.SetVisible(true); 
} 

If this answer is incomplete or I misunderstood your requirements, please let me know.
Thanks
Kate.
但是实际测试中发现了问题, throw 的时候后台直接抛出错误了,,这个方法也行不通,再找。。。
最终还是在官网上找到了解决方案,原文地址,我的代码如下:
 
protected void ASPxGridView1_CustomButtonCallback(object sender, ASPxGridViewCustomButtonCallbackEventArgs e) 
{ 
ASPxGridView view = sender as ASPxGridView; 
if (e.ButtonID == "btnAudit") 
{ 
int id = 0; 
int.TryParse(view.GetRowValues(e.VisibleIndex, "id").ToString(), out id); 
if (true) 
{ 
view.JSProperties["cpErrorMsg"] = "审核成功!"; 
view.DataBind(); 
} 
else 
{ 
view.JSProperties["cpErrorMsg"] = "此单据已经审核!"; 
} 
} 
} 

 
function EndCallBack(s, e) { 
if (s.cpErrorMsg!="") { 
alert(s.cpErrorMsg); 
} 
} 

这里要注意:JSProperties的参数必须以小写"cp"开头。
测试通过,呵呵

最新网友评论  共有(1)条评论 发布评论 返回顶部
hxnxssm 发布于2016-09-17 05:54:03
好的很,支持你!
支持(0)  反对(0)  回复

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务