Ajax controltoolkit Learning Log-confirmbuttonextender (7)

Source: Internet
Author: User
This control is used to remind the user whether to perform this operation after clicking the button in the browser of the client. If "yes" is clicked ", execute the event processing function of the button. If you click "no", cancel the operation.

The following is an example:

1) Create an ASP. NET Ajax-enabled web project in vs2005 and name it confirmbuttonextender1.

2) drag and drop an updatepanel control on the default. aspx page, and drag a linkbutton, A confirmbuttonextender, and a label in the control. Set the ID to linkbutton1, confirmbuttonextender1, and label1.

The view is as follows:

3) In confirmbuttonextender1, set targetcontrolid to linkbutton1, and in confirmtext to "are you sure you want to perform this operation? ".
CodeAs follows:

< C0: confirmbuttonextender ID = "Confirmbuttonextender1" Targetcontrolid = "Linkbutton1" Confirmtext = "Are you sure click the linkbutton? " Runat = "Server" > </ C0: confirmbuttonextender >

4) Add the code for executing the operation in the click event of linkbutton1:

1 Protected   Void Linkbutton#click1 ( Object Sender, eventargs E)
2 {
3This. Label1.text=Datetime. Now. tostring ();
4}

5) press Ctrl + F5 to view the effect in the browser.

Click linkbutton.

Click OK.

Note:
This control is easy to use, but pay attention to the usage of confirmbuttonextender:

1) confirmbuttonextender and the associated button control must be put together in updatepanel.
Or
2) confirmbuttonextender puts the button control associated with it out of the updatepanel, and sets the controlid as the button in asyncpostbacktrigger of triggers of updatepanel.

If you do not follow these steps, the following error may occur:
An Extender can't be in a different updatepanel than the control it extends.

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.