且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在按钮单击事件中触发动态按钮

更新时间:2022-01-14 04:40:49

为什么?只需将已放入click事件处理程序中的代码移至其自己的方法,然后从按钮click处理程序或您需要的其他任何位置调用即可.

完全没有理由单击"按钮来执行一段代码.
Why?? Just move the code that you''ve put in the click event handler to it''s own method and call it from the button click handler or from anywhere else you need to.

There''s very little reason to "Click" a button to execute a piece of code.


无论您希望在何处都可以发出click事件……..
rise the click event wherever you want like this........
btn.Click += new EventHandler(btn_Click);


然后您手动编写以下方法...........


then you manually write the below method...........

protected void btn_Click(objectsender e,Eventargs args)
{
}


简单.........


simple...........