ASP.NET ImageButton ValidationGroupProperty
ImageButton Control
Definition and Usage
When the ImageButton control is clicked, the OnClientClick property is used to set a client script to run.
In addition to the predefined script, the script specified in this property runs via the ImageButton's "OnClick" event.
Syntax
<asp:ImageButton OnClientClick="func" runat="server" />
| Property | Description |
|---|---|
| func | The client script that runs when the ImageButton is clicked. |
Example
The following example runs two scripts when the ImageButton control is clicked:
<script runat="server">
Sub script1(obj As Object, e As ImageClickEventArgs)
lblMsg.Text="Hello!"
End Sub
</script>
<form runat="server">
<asp:ImageButton OnClick="script1" OnClientClick="script2()"
ImageUrl="img.gif" runat="server" />
<br />
<asp:label id="lblMsg" runat="server" />
</form>
<script>
function script2()
{
return confirm('Hello!');
}
</script>
Sub script1(obj As Object, e As ImageClickEventArgs)
lblMsg.Text="Hello!"
End Sub
</script>
<form runat="server">
<asp:ImageButton OnClick="script1" OnClientClick="script2()"
ImageUrl="img.gif" runat="server" />
<br />
<asp:label id="lblMsg" runat="server" />
</form>
<script>
function script2()
{
return confirm('Hello!');
}
</script>
Demo Example »
ImageButton Control Other Extensions