如何动态地将控件添加到ASP.NET表单? [英] How to add controls dynamically to ASP.NET form?
本文介绍了如何动态地将控件添加到ASP.NET表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不知道该如何动态地添加控件使用C#.NET的形式。谁能帮我?我知道这与vb.net,但我需要知道在C#的语法。
I do not know how to add controls dynamically to the form using C# .net. Can anyone help me? I know this with vb.net but I need to know the syntax in C#.
推荐答案
在形式,下面的代码就可以动态地添加一个按钮:
In the form, the following code can add a button dynamically:
Button button1 = new Button();
button1.Text = "dynamic button";
button1.Left = 10; button1.Top = 10; //the button's location
this.Controls.Add(button1);
这篇关于如何动态地将控件添加到ASP.NET表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文