我正在將我的項目從2003年遷移到asp.net 2008.我的問題是關於只讀文本框。我有一些文本框爲只讀。2008年,我不能從這些文本框獲取值,如果readonly = true在aspx.So我寫一個函數轉換readonly = false,並添加readonly屬性在runtime.It運行良好,如果我的文本框不在更新面板。在更新面板中,頁面的控件不會來我的課,只有一個控制來它是UpdatePanel。如何在更新面板中獲得控件,如何更改它?我的代碼如下。我在每個頁面中調用它。在更新面板中更改控件的屬性
Public Shared Sub clearReadOnlyTextboxes(ByVal pg As Page)
For Each c As Control In pg.Form.Controls
If c.[GetType]().ToString() = "System.Web.UI.WebControls.TextBox" AndAlso DirectCast(c, TextBox).[ReadOnly] Then
DirectCast(c, TextBox).[ReadOnly] = False
DirectCast(c, TextBox).Attributes.Add("readonly", "readonly")
End If
Next
End Sub
你的意思是.NET 1.1到.NET 3.5?或Visula Studio 2003到Visual Studio 2008? – 2009-11-16 12:08:25
Visula Studio 2003到Visual Studio 2008.遷移後我使用.Net 3,5 ofcourse。 – Alexander 2009-11-16 12:16:49