Use the ymprompt script to check whether the gridview operation is deleted.

Source: Internet
Author: User

Solution: a prompt will be displayed during the delete operation, asking the user if they want to delete the file. The most commonly used is the confirm function of Js.

The advantage of using this function is that the reality is simple, and the disadvantage is: not beautiful

This is an article written to beautify confirm.

JS special effects code used for: http://download.csdn.net/detail/wangsky2/3909680

General idea: Create a server control button and a tag in the gridview delete operation template.

ASP: the button is set to invisible. The a mark is used to execute the JS script, and the background of the button is called to execute the operation in the execution of the JS script.

The Code is as follows:

<Asp: updatepanel id = "updatepanel2" runat = "server" childrenastriggers = "true">
<Contenttemplate>
<Asp: gridview id = "gvlist" runat = "server" autogeneratecolumns = "false" width = "100%"
Cssclass = "Table break" allowpaging = "true" ondatabound = "gvlist_databound"
Onrowdatabound = "gvlist_rowdatabound"
Onrowcommand = "delchilduserordevice"
Datakeynames = "ID, devid" onrowcancelingedit = "gvlist_rowcancelingedit"
Onrowediting = "gvlist_rowediting"
Onrowupdating = "gvlist_rowupdating" showheaderwhenempty = "true" gridlines = "NONE"
Cellpadding = "4" forecolor = "#333333">
<Columns>
Other data binding operations ......
<Asp: templatefield headertext = "operation">
<Itemtemplate>
<Asp: button id = "btndeldevice" commandname = "deldevice" runat = "server" text = "button" commandargument = "<% # container. dataitemindex %> "style =" display: none "/>
<A href = "javascript: deldevicerow (<% # container. dataitemindex %>);"> Delete </a>
</Itemtemplate>
</ASP: templatefield>
</Columns>
</ASP: gridview>
</Contenttemplate>
</ASP: updatepanel>

I used updatepanel to perform simple asynchronous refresh during deletion.

JS Code:

/// // Start ////////////////////////////////////
VaR devicedelrowindex; // Delete the index of the current row of the device.
// Delete the callback function of the device.
Function devicedelrowcallback (TP ){
If (TP = 'OK '){
VaR gridview = Document. getelementbyid ("<% = gvlist. clientid %> ");
Gridview. Rows [devicedelrowindex]. cells [4]. getelementsbytagname ("input") [0]. Click ();
}
}
// Delete a device's Function
Function deldevicerow (rowindex ){
Ymprompt. confirminfo ('Are you sure you want to delete this row? ', Null, null, 'message', devicedelrowcallback );
Devicedelrowindex = rowindex + 1;
}
/// // End/ ///////////////////////

Background deletion operation code:

Protected void delchilduserordevice (Object sender, gridviewcommandeventargs E)
{

Code ........

}

If you have a senior, please kindly advise ^_^

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.