The C1Button control can be used as a substitute for the standard ASP.NET button control. In the following example, we will demonstrate the client-side OnClientClick event by adding an OnClientClick event handler that writes text to a label when the event is fired. This topic assumes that you have created an AJAX-enabled ASP.NET project that contains a ScriptManager control (see Creating an AJAX-Enabled ASP.NET Project).
Complete the following steps:
1. Click the Design tab to enter Design view.
2. Place your cursor between the <form> and </form> tags.
3. From the Toolbox, add a standard Label control to your project.
4. From the Toolbox, add a C1Button control to your project.
5. Right-click the C1Button control to display its context menu and then select Properties from the list.
C1Button's properties are displayed in the Properties window.
6. Set the Text property to "Show Event".
7. Click the OnClientClick property's drop-down button and then select Add new client side handler to add the event handler to Source view. The event handler will appear as follows:
<script type="text/javascript" id="ComponentOneClientScript">
function C1Button1_OnClientClick(button, cancelArgs){
};
</script>
Observe that this action also set the C1Button's OnClientClick property to "C1Button1_OnClientClick", which is the default name of the event handler.
8. In Source view, add the following JavaScript, which handles the event and writes text to the label control, between the event handler's curly braces:
document.getElementById("Label1").innerHTML = "The OnClientClick event has been fired.";
9. Open the project and click the button. The label's text will change to "The OnClientClick event has been fired."