Latest web development tutorials

ASP.NET ImageButton OnClientClick property

ImageButton control ImageButton control

Definition and Usage

When the ImageButton control is clicked, OnClientClick attributes for client-side script is set to run.

In addition to predefined scripts, script specified in this property will be run by the ImageButton "OnClick" event.

grammar

<asp:ImageButton OnClientClick="func" runat="server" />

属性 描述
func 当 ImageButton 被点击时被运行的客户端脚本。


Examples

The following examples run two scripts 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>

The demonstration >>

ImageButton control ImageButton control