ButtonExtensions Module
Description
The ButtonExtensions Module contains several Extension Methods for the Button, ImageButton, and LinkButton controls to simplify the common task of adding a confirmation dialog using JavaScript when submitting a form.
Example




LinkButton Default
LinkButton Custom
Your most recently confirmed click was:

Properties & Methods
AddConfirmation()This Extension Method extends the Button, ImageButton, and LinkButton by adding a JavaScript confirmation dialog that appears when the button is clicked. The message displayed by the confirmation is "Are you sure you want to click the X button?", where X is button's Text or AlternateText property. AddConfirmation(ByVal msg As String)This Extension Method extends the Button, ImageButton, and LinkButton by adding a JavaScript confirmation dialog that appears when the button is clicked. The message displayed by the confirmation is the value entered for the msg parameter.
  • msg - The message displayed by the JavaScript confirmation
Source Code
ButtonExtensions.vb:

Remarks
We all know that it is not hard to manually add a confirmation, either declaratively or programmatically, so why would I bother to make this Extension Method? Well, mostly just because I enjoy writing code, but it can make things easier when you want to dynamically generate the confirmation message.