国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

aspxgridview CustomButtonCallback 不支持彈出消息提示解決方法

2020-01-17 23:52:06
字體:
供稿:網(wǎng)友
aspxgridveiw是devexpress的一個grid控件,使用起來還不錯。但是今天遇到一個問題,就是不能再 CustomButtonCallback 事件中使用response.write,因為CustomButtonCallback 事件是無刷新的,所以不支持,但是即使使用ScriptManager.RegisterClientScriptBlock(page, page.GetType(), "MyScript", myScript, true)也無濟于事,在網(wǎng)上查了很久,官方有個解決辦法,原文如下:
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:
復(fù)制代碼 代碼如下:

protected void ASPxGridView1_CustomButtonCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomButtonCallbackEventArgs e)
{
throw new Exception("Here I am!");
}

復(fù)制代碼 代碼如下:

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.
但是實際測試中發(fā)現(xiàn)了問題, throw 的時候后臺直接拋出錯誤了,,這個方法也行不通,再找。。。
最終還是在官網(wǎng)上找到了解決方案,原文地址,我的代碼如下:
復(fù)制代碼 代碼如下:

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"] = "此單據(jù)已經(jīng)審核!";
}
}
}

復(fù)制代碼 代碼如下:

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

這里要注意:JSProperties的參數(shù)必須以小寫"cp"開頭。
測試通過,呵呵
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 苗栗市| 保山市| 响水县| 观塘区| 辽阳市| 吴堡县| 苏尼特右旗| 奈曼旗| 兴海县| 黔西县| 奈曼旗| 琼结县| 岑巩县| 微山县| 吕梁市| 和硕县| 靖州| 武陟县| 通辽市| 澄江县| 牙克石市| 桃园县| 军事| 监利县| 闵行区| 昆明市| 桂林市| 灵丘县| 承德市| 中山市| 兴和县| 琼结县| 唐河县| 唐山市| 吕梁市| 铜鼓县| 盐源县| 聂拉木县| 鹤庆县| 盐源县| 新安县|