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
- String js = "return confirm('Do you really want to delete the record?');";
- btn.Attributes["onclick"] = js;
In this way, the HTML Tag contains an attribute:
- < 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.
- Modify the style of ASP. NET DataGrid
- ASP. NET DataGrid Control Data grouping operation
- What is the ASP. NET DataGrid Control: Fully templated Grid
- Comparison between ASP. NET's GridView and DataGrid controls
- . NET beginner's Guide: easily customize the DataGridView Control