Share via


onbuttonclick Event

Fires when a ToolbarCheckButton or ToolbarButton is clicked.

Syntax

Inline HTML <ELEMENT onbuttonclick = "handler" ... > All platforms
Event property object.onbuttonclick = handler Microsoft JScript only
object.onbuttonclick = GetRef("handler") Microsoft Visual Basic Scripting Edition (VBScript) 5.0 or later only
Named script <SCRIPT FOR = object EVENT = onbuttonclick> Internet Explorer only

Event Object Properties

Refer to the specific event object for additional event properties.

Example

The following example demonstrates how to use the OnButtonClick method. When an item is clicked within the Toolbar, server-side script is used to record user input events and display them in the div object at the bottom of the page.

<%@ Import Namespace="Microsoft.Web.UI.WebControls" %>
<%@ Register TagPrefix="mytb" 
Namespace="Microsoft.Web.UI.WebControls" 
Assembly="Microsoft.Web.UI.WebControls, Version=1.0.2.226, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>

<SCRIPT language="C#" runat="server">
public void ShowClick(Object sender,EventArgs e){
    ToolbarItem btn = (ToolbarItem)sender;
    debug.InnerText += "Clicked on object \"" + sender.ToString() + 
        "\" with index = \"" + myToolbar.Items.FlatIndexOf(btn).ToString()
        + "\" ";
}
private void Page_Load(object sender, System.EventArgs e){
    debug.InnerText ="";
}
</SCRIPT>
<HTML>

<BODY>

<FORM runat="server">
<mytb:Toolbar runat="server" id="myToolbar" OnButtonClick="ShowClick" AutoPostBack="true">
    
    <mytb:ToolbarCheckButton id="Mode_Change"
        Tooltip="Change the ToolBar mode"
        ImageUrl="images/tool-dayview.gif"
        Text="Calendar Mode" />
    <mytb:ToolbarSeparator id="Separator_1" />
    <mytb:ToolbarCheckGroup id="Group_A">
        <mytb:ToolbarCheckButton id="Button_A_1" Text="GroupA-1" />
        <mytb:ToolbarCheckButton id="Button_A_2" Text="GroupA-2" />
    </mytb:ToolbarCheckGroup>
    <mytb:ToolbarSeparator id="Separator_2"/>
    <mytb:ToolbarCheckGroup id="Group_B">
        <mytb:ToolbarCheckButton id="Button_B_1" Text="GroupB-1" Selected="True" />
        <mytb:ToolbarCheckButton id="Button_B_2" Text="GroupB-2" />
        <mytb:ToolbarCheckButton id="Button_B_3" Text="GroupB-3" />
    </mytb:ToolbarCheckGroup>
</mytb:Toolbar>
</FORM>
<P>User Input Information:<BR>
<DIV id=debug runat="server"
    style="border:1 solid black;background:beige;width:500;height:50">
</DIV>
</P>
</BODY>
</HTML>

Applies To

TOOLBAR, TOOLBARBUTTON, TOOLBARCHECKBUTTON, TOOLBARCHECKGROUP

See Also

Internet Explorer WebControls, About the Toolbar WebControl