Y
yesming2002
hi~~
System.Web.UI.WebControls.HyperLink doesn't supply the OnClick eventHandler.
i inherit the HyperLink class and want to add a OnClick event.But it dosen't work.
here is the code. THX for any reply!
public class MyLink:System.Web.UI.WebControls.HyperLink
{
public event System.EventHandler Click;
protected void OnClick(EventArgs e)
{
if(Click!=null) Click(this,e);
}
protected void Reset()
{
Click=null;
}
}
public class MyPage: System.Web.UI.Page
{
....
//in the Page_load
private void Page_Load(object sender, System.EventArgs e)
{
link=new MyLink();
link.Click+=new System.EventHandler(this.link_Click);
}
.....
void link_Click
{
//do something when link clicked.
}
}
System.Web.UI.WebControls.HyperLink doesn't supply the OnClick eventHandler.
i inherit the HyperLink class and want to add a OnClick event.But it dosen't work.
here is the code. THX for any reply!
public class MyLink:System.Web.UI.WebControls.HyperLink
{
public event System.EventHandler Click;
protected void OnClick(EventArgs e)
{
if(Click!=null) Click(this,e);
}
protected void Reset()
{
Click=null;
}
}
public class MyPage: System.Web.UI.Page
{
....
//in the Page_load
private void Page_Load(object sender, System.EventArgs e)
{
link=new MyLink();
link.Click+=new System.EventHandler(this.link_Click);
}
.....
void link_Click
{
//do something when link clicked.
}
}