2016-03-01 48 views
0

我需要從Web窗體上的文本框中獲取文本值。在文檔中提到System.Web.UI.WebControl.Textbox有一個屬性Text,但是當我嘗試使用它時出現錯誤。System.Web.UI.WebControl.Textbox不包含文本的定義

string FieldName= ""; 
string FieldValue=""; 
if (inputValues[i] is System.Web.UI.WebControls.TextBox) 
{ 
    FieldName = inputValues[i].ClientID; 
    FieldValue = inputValues[i].Text; // error 
} 

顯示的錯誤是System.Web.UI.WebControl.Textbox does not contain the definition of Text。如何從文本框控件獲取文本值?

+1

什麼是inputValues類型? – Adil

回答

1

嘗試鑄造inputValues[i]System.Web.UI.WebControl.Textbox。然後訪問Text屬性:

FieldValue = ((System.Web.UI.WebControl.Textbox)(inputValues[i])).Text;