我想实现imageButton控件的单击事件,代码如下:
lx.asp文件中的代码:
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="MyfirstAspx.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<script language="javascript">
function alertClick()
{
alert("你单击的是客户端Button控件!");
}
</script>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
&nbsp;&nbsp;
<asp:button id="MysortButton" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 16px"
runat="server" Width="104px" Text="Sort"></asp:button><asp:button id="MynosortButton" style="Z-INDEX: 102; LEFT: 136px; POSITION: absolute; TOP: 16px"
runat="server" Width="96px" Text="Nosort"></asp:button>
<asp:label id="Wordlab" style="Z-INDEX: 103; LEFT: 16px; POSITION: absolute; TOP: 56px" runat="server"
Width="216px" Height="24px">asdlweihfauhq</asp:label><asp:linkbutton id="LinkButton1" style="Z-INDEX: 104; LEFT: 16px; POSITION: absolute; TOP: 88px"
runat="server" Width="96px" Height="24px">MySortButton</asp:linkbutton><asp:linkbutton id="LinkButton2" style="Z-INDEX: 105; LEFT: 136px; POSITION: absolute; TOP: 88px"
runat="server" Width="96px" Height="16px" Text="MyNoSortButton"></asp:linkbutton>
<asp:ImageButton id="MyImageButton" style="Z-INDEX: 106; LEFT: 16px; POSITION: absolute; TOP: 128px"
runat="server" Width="200px" Height="40px" ImageUrl="images/bluemoon.jpg"></asp:ImageButton>
<asp:Label id="ImageIndex" runat="server" Width="296px" style="Z-INDEX: 107; LEFT: 16px; POSITION: absolute; TOP: 184px">图像按钮的坐标为:</asp:Label></form>
</body>
</HTML>lx.aspx.cs文件中的代码:
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;namespace MyfirstAspx
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button myStoreButton;
protected System.Web.UI.WebControls.Button myNostoreButton;

private String word = "";
protected System.Web.UI.WebControls.Button MysortButton;
protected System.Web.UI.WebControls.Label ImageIndex;
protected System.Web.UI.WebControls.Button MynosortButton;
protected System.Web.UI.WebControls.LinkButton LinkButton1;
protected System.Web.UI.WebControls.LinkButton LinkButton2;
protected System.Web.UI.WebControls.Label Wordlab;
protected System.Web.UI.WebControls.ImageButton MyImageButton;
private String wordTemp = ""; private void InitializeComponent()
{ } private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
} //MyImageButton.Click = new System.Web.UI.ImageClickEventHandler(MyImageButton_Click);

private void MyImageButton_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
ImageIndex.Text="图像按钮坐标是:(x:" + e.X.ToString()+" y:"+ e.Y.ToString() +")";
}
}
}程序可以运行但是点击ImageButton控件没有反应,请问文是什么问题?