2011-05-02 118 views
0

如何在运行时按钮单击时创建尽可能多的文本框。还有什么将在运行时创建的文本框的id和通过会话发送文本框的值到下一页在运行时创建文本框

请有人帮助我。我在这个问题上困扰了很多天,但无法解决它。

感谢

人员Prasanna

回答

1

若要在您设置它在你的Page_Init这样运行一个文本框:

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 
    ' Create dynamic controls here. 
    TextBox1 = New TextBox() 
    TextBox1.ID = "TextBox1" 
    TextBox1.Style("Position") = "Absolute" 
    TextBox1.Style("Top") = "25px" 
    TextBox1.Style("Left") = "100px" 
    Form1.Controls.Add(TextBox1) 

    TextBox2 = New TextBox() 
    TextBox2.ID = "TextBox2" 
    TextBox2.Style("Position") = "Absolute" 
    TextBox2.Style("Top") = "60px" 
    TextBox2.Style("Left") = "100px" 
    Form1.Controls.Add(TextBox2) 

End Sub 
0

在ASP.Net创建动态控件可以是有点棘手。原因是在Page_Init不会存储在视图状态之后创建的任何控件。这意味着对于Page_Init创建的控件,在页面上发回的输入到控件中的数据将丢失。此外,事件不会为这些控件触发。

好三个部分组成的文章可以在这里找到
http://www.4guysfromrolla.com/articles/081402-1.aspx