ASP.NET中ImageButton图片按钮控件的使用
ImageButton说白了,就是一个能显示图片的按钮,用法和Button基本一致,无非就是点击之后触发事件,只是比Button展现更丰富一些。
一、常见ImageButton属性
二、ImageButton实例演示
前台代码ImageButton.aspx
<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="ImageButton.aspx.cs"Inherits="WebControls_ImageButton"%>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title></title>
</head>
<body>
<formid="form1"runat="server">
<div>
<asp:ImageButtonID="ibtn"runat="server"Height="20px"ImageUrl="http://images.cnblogs.com/cnblogs_com/ylbtech/403178/o_sanyecao.jpg"
ToolTip="前台指向"Width="118px"/>
<br/>
<br/>
<asp:ImageButtonID="ibtn2"runat="server"Height="20px"ImageUrl="http://images.cnblogs.com/cnblogs_com/ylbtech/403178/o_sanyecao.jpg"
ToolTip="后台指向"Width="118px"onclick="ibtn2_Click"/>
</div>
</form>
</body>
</html>
后台代码ImageButton.aspx.cs
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
publicpartialclassWebControls_ImageButton:System.Web.UI.Page
{
protectedvoidPage_Load(objectsender,EventArgse)
{
}
protectedvoidibtn2_Click(objectsender,ImageClickEventArgse)
{
//方法内可以做很多操作
//注册,注册成功,跳转到主页
Response.Redirect("~/DemoHTML.aspx");
}
}