July 9, 2009

當TextBox的ReadOnly屬性為true時,Postback後無法讀取TextBox之值

是的。

Postback之後請改用Request.Form[this.TextBox.UniqueID]取得TextBox之值。或是改用TextBox.Attributes.Add("readonly", "readonly")來設定TextBox為readonly而不直接設定TextBox的ReadOnly屬性


參考
http://west-wind.com/weblog/posts/3939.aspx
http://www.codeproject.com/KB/aspnet/Readonly.aspx
http://www.g9th.com/blog/post/2006/12/Readonly-property-of-Textbox-in-ASPNET.aspx

No comments: