ConfirmButtonExtender Control

The ConfirmButtonExtender control, as the name suggests, captures the Click event of a button and displays a confirmation dialog box. If the user clicks OK after that, the button will function as implemented; otherwise, the Click event will simply be ignored. This control is so simple that it only has two properties: TargetControlID and ConfirmText. As you probably have guessed already, TargetControlID contains the ID of the target button, and ConfirmText holds the text message that will be displayed in the dialog box requiring user confirmation.

The ConfirmButtonExtender control is ideal in situations where the user is about to submit an order or other important unit of data. It works equally well with ASP.NET Button and LinkButton controls. To see this in a page, create an ASP.NET button control on a page followed by the ConfirmButtonExtender control. After that, set the TargetControlID property of your ConfirmButtonExtender control to that of the regular button, and set the text for the ConfirmText property. Lastly, create a Label control, and in the event handler for the button, set the label's text to a message indicating the successful receipt of the Click event. Your ASPX markup should look similar to the following code snippet:

<asp:Button ID="Button1" runat="server" Text="Submit"^-

OnQick="Button1_Qick" /> <cc1:ConfirmButtonExtender ID="ConfirmButtonExtender1"

TargetControlID="Button1" ConfirmText="Are you sure ?" runat="server"> </cc1:ConfirmButtonExtender><br /> <asp:Label ID="Label1" runat="server" Width="360px"></asp:Label>

When you click this submit button, you will be presented with a dialog box as shown in Figure 7-16.

Figure 7-16. Dialog box of the ConfirmButtonExtender control

If you cancel the dialog box, the initial Click event of the Submit button will be discarded. However, if you click OK, the Click event is accepted, and the click-event method is invoked. The click-event method displays a confirmation message in the Label control as shown in Figure 7-17.

Figure 7-17. Submit button accepted
0 0

Post a comment

  • Receive news updates via email from this site