如何使用ASP.NET动态创建文本框 [英] How to Dynamically create textboxes using ASP.NET
本文介绍了如何使用ASP.NET动态创建文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用ASP.NET动态创建文本框
How to Dynamically create textboxes using ASP.NET
推荐答案
TextBox newText = new TextBox();
newText.ID = "newText";
newText.Text="I am a new TextBox";
Form.Controls.Add(newText);
这是来自内存。但试一试,如果您有问题请告诉我们。
This is from memory. But give that a try and let us know if you have issues.
HI,
查看以下链接以便更好地理解。
代码:在运行时添加控件(Visual C#)
动态地向ASP.NET表单添加控件
ASP.NET动态控件
谢谢
Checkout these following links for better understanding.
Code: Adding Controls at Run Time (Visual C#)
Adding Controls to an ASP.NET form Dynamically
ASP.NET Dynamic Controls
Thanks
嗨亲爱的使用这种技术。
Hi Dear use this technique.
private void CreateTextBox()
{
for (int i = 0; i < 3; i++)
{
TextBox txtBox = new TextBox();
txtBox.ID = "Txt" + Convert.ToString(i + 1);
txtBox.Text = "TextBox" + Convert.ToString(i + 1);
this.Panel1.Controls.Add(txtBox);
}
}
这篇关于如何使用ASP.NET动态创建文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文