本文介绍了如何创建动态按钮属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:-我想创建一个动态按钮,并想在该动态按钮的属性中编写代码?
我的代码如下,但它不起作用:

question :- i want to create one dynamic button and want to write code in the property of this dynamic button?
my code is followes but it doesnt work:

Button btn = new Button();
                btn.Text = "Add As Friend!";
                btn.ID = "Button1";
                                
                
                btn.Click += new System.EventHandler(btn_Click);
//
protected void btn_Click(object sender, EventArgs e)
       {

       }


错误将出现在以下行中:


error will comes int the following line:

btn.Click += new System.EventHandler(btn_Click);



请帮我!

提前thanx



plz help me!

thanx in advance

推荐答案

protected System.Web.UI.WebControls.Button btn;
protected void Page_Load(object sender, EventArgs e)
{
           btn = new Button();
            btn.Text = "Add As Friend!";
            btn.ID = "Button1";
            this.btn.Click += new System.EventHandler(btn_Click);
}
protected void btn_Click(object sender, EventArgs e)
{

}


最好的问候
M.Mitwalli


Best Regards
M.Mitwalli



这篇关于如何创建动态按钮属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 21:25