动态创建linkbutton时如何在LinkButton_Click事件上编写代码 [英] How to write code on LinkButton_Click event when linkbutton created dynamically
本文介绍了动态创建linkbutton时如何在LinkButton_Click事件上编写代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的应用程序中,我动态创建标签和链接按钮.标签显示数据库值,并且链接按钮用于删除标签值的记录.但是我不知道如何在动态创建的
In my application i m dynamically create label and linkbutton. label shows the database value and link button is used to delete record of label value. but i dont know how to write code on
LinkButton_Click event
上编写代码.
推荐答案
动态创建linkbutton时的LinkButton_Click事件
LinkButton是动态创建的,但您可能知道单击会发生什么-先编写事件,然后在创建linkbutton时引用/绑定此事件.另外,您也可以在创建事件时创建匿名方法.
LinkButton_Click event when linkbutton created dynamically
LinkButton is created dynamically, but you might be knowing what the click would do - write the event before hand and refer/bind this event at the time of creating the linkbutton. Alternatively, you can also create anonymous method at the time of creation for the event.
protected void Page_Load(object sender, EventArgs e)
{
LinkButton taha = new LinkButton();
taha.Text = "Click On Me";
taha.Click +=LinkClick;
Panel1.Controls.Add(taha);
}
protected void LinkClick(object sender, EventArgs e)
{
Response.Write("Hello");
}
这篇关于动态创建linkbutton时如何在LinkButton_Click事件上编写代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文