ASP.NET中ImageButton图片按钮控件的使用
金哲夫,拉菲娱乐q67921,王冠第二季
imagebutton 说白了,就是一个能显示图片的按钮,用法和button基本一致,无非就是点击之后触发事件,只是比button展现更丰富一些。
一、常见 imagebutton 属性
属性 |
描述 |
imageurl |
在 imagebutton 控件中显示的图像的路径。 |
tooltip |
提示的文本。 |
alternatetext |
图像无法显示时显示的文本。 |
二、imagebutton实例演示
前台代码 imagebutton.aspx
<%@ page language="c#" autoeventwireup="true" codefile="imagebutton.aspx.cs" inherits="webcontrols_imagebutton" %>
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "">
<html xmlns="">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:imagebutton id="ibtn" runat="server" height="20px" imageurl=""
tooltip="前台指向" width="118px" />
<br />
<br />
<asp:imagebutton id="ibtn2" runat="server" height="20px" imageurl=""
tooltip="后台指向" width="118px" onclick="ibtn2_click" />
</div>
</form>
</body>
</html>
后台代码 imagebutton.aspx.cs
using system;
using system.collections.generic;
using system.web;
using system.web.ui;
using system.web.ui.webcontrols;
public partial class webcontrols_imagebutton : system.web.ui.page
{
protected void page_load(object sender, eventargs e)
{
}
protected void ibtn2_click(object sender, imageclickeventargs e)
{
//方法内可以做很多操作
//注册,注册成功,跳转到主页
response.redirect("~/demohtml.aspx");
}
}
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!!
点击进行留言回复
网友评论