ASP. NET DataGrid tips: confirmation dialog box for key tasks

Source: Internet
Author: User

Dialog bar of ASP. NET DataGrid skills: Confirmation of key tasks

How can I display a dialog box that forces a user to confirm before starting a key task such as deleting a record?

Assume that you need to click a button to display such a dialog box. Okay. You only need some client JavaScript code to handle the onclick event.

Any ASP. NET control can be followed by one or more HTML tags. The down button maps to the "button" tag. The link button maps to a script-driven hyperlink. Use the Attributes set of the ASP. NET Control to register the script code segment for both tags. For example, if you have a Button, whether it is a LinkButton object or a Button object, you can define the JavaScript code that runs after the Button is clicked, as shown below:

ASP. NET DataGrid: confirmation dialog box implementation

 
 
  1. String js = "return confirm('Do you really want to delete the record?');";  
  2. btn.Attributes["onclick"] = js;  

In this way, the HTML Tag contains an attribute:

 
 
  1. < a  ? onclick="return confirm(' ? ')">   

When you click the link, The onclick client code is run. If you click No, the event is automatically abandoned. This behavior is embedded into the logic of the browser, which is almost irrelevant to ASP. NET. If the onclick client handler exits successfully, the _ doPostBack function is executed and the page is sent back to the server.

The above is the ASP. NET DataGrid technique: Implementation of the force-start confirmation dialog box.

  1. Modify the style of ASP. NET DataGrid
  2. ASP. NET DataGrid Control Data grouping operation
  3. What is the ASP. NET DataGrid Control: Fully templated Grid
  4. Comparison between ASP. NET's GridView and DataGrid controls
  5. . NET beginner's Guide: easily customize the DataGridView Control

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.