Aspxgridview Custombuttoncallback does not support pop-up message prompt workaround _ Practical Tips

Source: Internet
Author: User
ASPXGRIDVEIW is a grid control for DevExpress, and it's good to use. Today, however, there is a problem that you cannot use Response.Write in Custombuttoncallback events because the Custombuttoncallback event is not refreshed, so it is not supported, But even with Scriptmanager.registerclientscriptblock (page, page). GetType (), "MyScript", MyScript, true) also did not help, the online search for a long time, the official has a solution, the original text is as follows:
Hi Troy;
To provide this functionality you should throw a exception in the Custombuttoncallback event handler and process this exc Eption in the Callbackerror event handler. Here are the simple sample:
Copy Code code as follows:

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

Copy Code code as follows:

if (e.message = = ' here I am! ')
{
Clienterrorimage.setvisible (TRUE);
}

If This answer are incomplete or I misunderstood your requirements, please let me know.
Thanks
Kate.
But the actual test found the problem, throw when the background directly thrown wrong, and this method is not workable, and then find ...
Finally found the solution on the official web, the original address, my code is as follows:
Copy Code code 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 success!" ";
View. DataBind ();
}
Else
{
View. jsproperties["cperrormsg"] = "This document has been approved!" ";
}
}
}

Copy Code code as follows:

function Endcallback (s, e) {
if (s.cperrormsg!= "") {
alert (s.cperrormsg);
}
}

Note here: The jsproperties parameter must begin with a lowercase "cp".
Test Pass, hehe

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.