我真的快瘋了﹐自定義webcontrol里怎沒觸發onclick事件啊﹗各位救救我吧
代碼就如下﹕但為什么創建的控件click跟本沒觸發啊
webform1.aspx
====================
<%@ Register TagPrefix="ctl" Namespace="testControl" Assembly="testControl" %>
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="testControl.WebForm1" %>
<HTML>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<ctl:testCtl id="ctl1" runat="server"></ctl:testCtl>
</form>
</body>
</HTML>
testCtl.cs
================================================
using System;
using System.Web.UI.WebControls;
namespace testControl
{
public class testCtl : System.Web.UI.WebControls.WebControl
{
public testCtl()
{
}
protected override void Render(System.Web.UI.HtmlTextWriter output)
{
Button btn=new Button();
btn.Text="adfasdfgagajsdkladfj";
btn.Click += new EventHandler(this.btnDra_Click);
Controls.Add(btn);
this.RenderChildren(output);
}
private void btnDra_Click(object sender, System.EventArgs e)
{
Context.Response.Redirect("webform.aspx?abc=e");//這里我故意寫成webform.aspx
return;//這個應該沒用的
}
}
}