2010-10-19 27 views
0

我有一個類CURPRFC包含以下內容:如何通過文本框的值的方法或功能

static public string CalcRFC(string firstname, string lastname, string middlename, string date) 

我在我的代碼隱藏調用此方法/功能如下:

CURPRFC.CalcRFC(txtfirstname.text, txtlastname.text, txtmidlename.text, txtdate.text) 

其中每個值都是文本框值。但是,我收到一個錯誤消息:

System.Web.UI.WebControls.TextBox' does not contain a definition for 'text' and no extension method 'text' accepting a first argument of type 'System.Web.UI.WebControls.TextBox' could be found (are you missing a using directive or an assembly reference?) 

我的C#有點弱。我想我需要將我的文本框文本值更改爲字符串,但不知道如何去做這件事。我在正確的軌道上嗎?

您的幫助是最感謝!

感謝, 希德

回答

3

你要記住,C#是區分大小寫的。文本框沒有一個text屬性,但它確實有一個Text屬性:

CURPRFC.CalcRFC(txtfirstname.Text, txtlastname.Text, 
       txtmidlename.Text, txtdate.Text); 

(我還建議你想想命名清晰 - 傳統C#變量使用camelCasing指示斷字,而一個類名爲「CURPRFC」遠不言自明。)