aspxgridview CustomButtonCallback 不支持弹出消息提示
来源:互联网 发布:gov.cn域名代注册 编辑:程序博客网 时间:2024/06/06 05:26
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"开头。
测试通过,呵呵
本文由麻辣烫加盟网转载发布,转载请注明,谢谢
- aspxgridview CustomButtonCallback 不支持弹出消息提示
- aspxgridview CustomButtonCallback 不支持弹出消息提示
- ASPxGridView提示不支持所指定的方法的解决方法
- 弹出提示消息层
- 仿QQ弹出消息提示
- 做及时 提示 弹出消息
- javascript弹出消息提示框
- 自动弹出一个消息提示
- Sharepoint 弹出消息提示框
- ASPxGridView修改,删除,增加提示“不支持所指定的方法”的原因
- ASPxGridView删除、添加、修改成功后,弹出提示对话框的方法
- 页面右下角弹出的消息提示代码
- C#弹出消息提示框方法
- .net后台弹出提示消息代码
- 用PHP实现弹出消息提示框
- Android自定义Toast弹出消息提示
- iOS弹出对话框提示字符串消息
- JOptionPane java 弹出对话框 消息提示框
- VMware vSphere 服务器虚拟化之十七 桌面虚拟化之安装View链接服务器
- mkdir递归创建目录
- 李代数(第2版)
- static_cast
- 堆和栈
- aspxgridview CustomButtonCallback 不支持弹出消息提示
- 接口定义语言(IDL)简介
- Oracle 常用command
- 求n个字符的长度为m的组合
- ActionScript使用正则表达式
- 类
- 写给四年前刚开始写程序的自己
- JS伪3D 图形透视效果
- DEVICE_ATTR 和 sysfs 的东西 -- sysfs_create_group