2016-03-01 154 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;