Tips for combining jquery with ASP. net2.0

Source: Internet
Author: User
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 " );

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.