ImageButton To put it bluntly, it is a button that can display images. Its usage is basically the same as Button. It is nothing more than triggering events after clicking, but it is more richer than Button's display.
1. Common ImageButton properties
property | describe |
---|---|
ImageUrl | The path to the image displayed in the ImageButton control. |
ToolTip | Prompt text. |
AlternateText | Text displayed when the image cannot be displayed. |
two,ImageButtonExample Demonstration
Front Desk Code
Copy the codeThe code is as follows:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="" Inherits="WebControls_ImageButton" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:///TR/xhtml1/DTD/">
<html xmlns="http:///1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form runat="server">
<div>
<asp:ImageButton ID="ibtn" runat="server" Height="20px" ImageUrl="/cnblogs_com/ylbtech/403178/o_sanyecao.jpg"
ToolTip="Foreground Points to" Width="118px" />
<br />
<br />
<asp:ImageButton ID="ibtn2" runat="server" Height="20px" ImageUrl="/cnblogs_com/ylbtech/403178/o_sanyecao.jpg"
ToolTip="Background pointer" Width="118px" onclick="ibtn2_Click" />
</div>
</form>
</body>
</html>
Background code
Copy the codeThe code is as follows:
using System;
using ;
using ;
using ;
using ;
public partial class WebControls_ImageButton :
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void ibtn2_Click(object sender, ImageClickEventArgs e)
{
//A lot of operations can be done within the method
//Register, register successfully, jump to the homepage
("~/");
}
}