动态添加的控件要怎么才能得到它的值呢?谢谢
开发环境 Microsoft Visual Studio 2005 ASP.Net2.0
Default.aspx文件
<%@ Page Language= "VB " AutoEventWireup= "false " CodeFile= "Default.aspx.vb " Inherits= "_Default " %>
<html xmlns= "http://www.w3.org/1999/xhtml " >
<head runat= "server ">
<title> 无标题页 </title>
</head>
<body>
<form id= "form1 " runat= "server ">
<div>
<asp:Button ID= "Button1 " runat= "server " Text= "Button " />
<asp:Panel ID= "Panel1 " runat= "server " Height= "120px " Width= "176px ">
</asp:Panel>
</div>
</form>
</body>
</html>
'--------------Default.aspx文件完-------------
Default.aspx.vb文件
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim T As System.Web.UI.WebControls.TextBox = Me.Session.Item( "T ")
If T Is Nothing Then
'动态添加一个TextBox
T = New System.Web.UI.WebControls.TextBox
Me.Session.Add( "T ", T)
Else
Dim R As String = T.Text
'请问为什么T.Text是空的呢?
End If
Panel1.Controls.Add(T)
End Sub
End Class
'--------------Default.aspx.vb文件完-------------
当我在IE中修改T的Text后点击Button后T的Text的内容还是为空呢。
要怎么才能得到动态添加的TextBox的被修改后的Text呢。
谢谢
------解决方案--------------------生成控件时给它一个名称MyText1
string tmp = Request.Form[ "MyText1 "]