开发者

How to Pass Textbox Value to Method or Function

I have a class CURPRFC that contains the following:

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

I'm calling this method/function in my codebehind as follows:

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

where each of the values are textbox values. However, I receive an error stating:

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?)

My C# is a bit weak. I think I need to change my textbox text values to strings, but am not sure of how to go about this. Am I on th开发者_如何学编程e right track?

Your help is most appreciated!

Thanks, Sid


You need to remember that C# is case-sensitive. TextBox doesn't have a text property, but it does have a Text property:

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

(I'd also suggest that you think about naming clarity - conventionally C# variables use camelCasing to indicate word breaks, and a class named "CURPRFC" is far from self-explanatory.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜