When you create a USB flash drive for a network today, you need to give a warning when you delete a specified file.
First, this is done, button1.attartutes. Add ("onclick", "Return
Confirm ('Are you sure you want to delete it? ') "); Finally, it is found that no matter whether you select 'yes' or 'no', the serverclick event of button1 in the background will not be executed.
Set 'Return
Confirm ('Are you sure you want to delete it? ')' To 'Confirm ('Are you sure you want to delete it? ')'. It is found that no matter whether 'yes' or 'no' is selected, the background button1
Serverclick event, finally come up with a way, put a server control button on the page, the ID is 'btndelete', this button to perform the delete operation, and then
Change button1 to a client control as follows,
HTML:
<Input type = 'button 'value = 'Delete 'onclick = "confirmclick ()">
<Asp: button id = 'btndelete' text = "" onclick = "btndelete_click" style = "display: none" runat = "server"> </ASP: button>
JS:
Function confirmclick (){
If (confrim ("are you sure you want to delete it? "))
Document. All. btndelete. Click ();
}
Hide the button that actually executes the delete operation and turn a bend to implement the confirm function. In the red part, some people will say that in vs2005, enter the button in the server control label.
The 'style' and other words do not prompt intelligently. It's okay, just close your eyes and write it, because these server controls will eventually become general client controls after compilation, for example
'Document. All. btndelete. Click (); 'is.
Found a simpler way to implement this function, and modified the above example
<Asp: button id = 'btndelete' text = "" onclick = "btndelete_click" onclientclick = "Return confrim (" are you sure you want to delete it? ")"> </ASP: button>
The above paragraph can implement the functions of the previous example. IE6 test successful!