Main functions, simplified Code To bring up a dialog box prompt before the deletion function.
Many ASP. net2.0 data controls have the delete function. Users are usually prompted before the delete operation. In the previous method, we wrote the custom onclick Attribute before the linkbutton control. Now we have jquery, which can be implemented in this way. The Code only supports linkbutton deletion and does not support button! /**/ /// <Summary>
///The operation dialog box is displayed, which must be supported by jquery.
/// </Summary>
/// <Param name = "message"> </param>
/// <Param name = "hreftext"> </param>
Public Static Void Confirmcommandmessageusejquery (page, String Message, String Commandtype)
{
String JS = " $ (Document). Ready (function () {var arr = $ (\ " A \ " ); Arr. Each (function () {var S = This. href; If (S. indexof (\ "" + Commandtype + " \ " )! =-1) {$ (this). Click (function () {return confirm (' " + Message + " ');});}});}); " ;
Clientscriptmanager CS = Page. clientscript;
If ( ! CS. isstartupscriptregistered ( " Jquerydelete " ))
{
CS. registerstartupscript (Typeof(Page ),"Jquerydelete", JS,True);
}
}
Protected Void Page_load ( Object Sender, eventargs E)
{
Clientscriptmanager CS = Page. clientscript;
If ( ! CS. isclientscriptincluderegistered ( Typeof (Page ), " Jquery " )) // Register jquery
{
CS. registerclientscriptinclude (Typeof(Page ),"Jquery", Resolveurl ("~ /JS/jquery. js"));
}
}
call JScript. confirmcommandmessageusejquery ( This , " are you sure you want to delete the user, deleting a user will delete other related records of the user. Please be careful! " , " Delete " );