Dinamik buton ve onclick eventi oluşturmak
Dinamik buton ve onclick event oluşturma.
<
asp:Panel
ID
=
"p1"
runat
=
"server"
>
</
asp:Panel
>
<
asp:Label
ID
=
"lblmsj"
runat
=
"server"
Text
=
""
></
asp:Label
>
protected
void
Page_Load(
object
sender, EventArgs e)
{
Button YeniButon =
new
Button();
YeniButon.ID=
"btn"
;
YeniButon.Text =
"omer"
;
YeniButon.Click +=
new
EventHandler(YeniButon_Click);
p1.Controls.Add(YeniButon);
}
protected
void
YeniButon_Click(
object
sender, EventArgs e)
{
lblmsj.Text =
"Merhaba"
;
}