What if CustomButtonCallback does not support pop-up message prompts in aspxgridview
This article will explain in detail what to do about the pop-up message prompt that CustomButtonCallback does not support in aspxgridview. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Aspxgridveiw is a grid control of devexpress, and it works well. However, a problem encountered today is that you can no longer use response.write in the CustomButtonCallback event, because the CustomButtonCallback event is not refreshed, so it is not supported, but even if you use ScriptManager.RegisterClientScriptBlock (page, page.GetType (), "MyScript", myScript, true), it will not help. After searching the Internet for a long time, there is an official solution. The original text is as follows:
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:
The code is as follows:
Protected void ASPxGridView1_CustomButtonCallback (object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomButtonCallbackEventArgs e)
{
Throw new Exception ("Here I am!")
}
The code is as follows:
If (e.message = = 'Here I amalgamated')
{
ClientErrorImage.SetVisible (true)
}
If this answer is incomplete or I misunderstood your requirements, please let me know.
Thanks
Kate.
But the actual test found a problem, throw when the background directly threw an error, this method does not work, find again.
Finally, I found the solution on the official website, the original address, my code is as follows:
The code 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"] = "Audit succeeded!"
View.DataBind ()
}
Else
{
View.JSProperties ["cpErrorMsg"] = "this document has been audited!"
}
}
}
The code is as follows:
Function EndCallBack (s, e) {
If (s.cpErrorMsgears = "") {
Alert (s.cpErrorMsg)
}
}
Note here that the argument to JSProperties must start with a lowercase "cp".
This is the end of the article on "what to do if CustomButtonCallback does not support pop-up messages in aspxgridview". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.