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.