aspxgridview CustomButtonCallback does not support pop up message prompt solutions

  • 2020-06-12 08:51:03
  • OfStack

aspxgridveiw is an grid control of devexpress and works well. However, I have a problem today. It is impossible to use ES4en.write in CustomButtonCallback event, because CustomButtonCallback event is not refreshed, so it is not supported. However, even using ES7en.RegisterClientScriptBlock (page, page.GetType (), "MyScript", myScript, true) is of no help.
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.
However, problems were found in the actual test. During throw, the background directly threw an error, and this method also failed.
Finally, I found a solution on the official website. The original address is as follows:
 
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"] = " Successful audit! "; 
view.DataBind(); 
} 
else 
{ 
view.JSProperties["cpErrorMsg"] = " This document has been reviewed! "; 
} 
} 
} 

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

Note here: the argument to JSProperties must begin with a lowercase "cp".
The test passed, hehe

Related articles: