. NET Server control button-confirm

Source: Internet
Author: User

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!

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.