Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to convert a textbox.text to string?

Status
Not open for further replies.

onechuck

IS-IT--Management
Feb 14, 2006
79
US
I have a couple of textboxes that I am trying to concatenate and I receive some error about that. Here's what I have.

string strSummary;

strSummary = txtFstName.Text + " " + txtLstName.Text;

The error message is:

Cannot convert from 'System.Web.UI.WebControls.TextBox' to 'string'

Your help is appreciated.
 
Well, Textbox.Text does return a string. You can .ToString() anything to force a string conversion, but I wonder if you didn't name your textbox itself txtFstName.Text instead of just txtFstName?

That's my best guess just from that snippet. Maybe someone else has a guess.

----------------------------------------

TWljcm8kb2Z0J3MgIzEgRmFuIQ==
 
You're right. That wasn't the problem. It's something else. I got it fixed now. Thanks!
 
What was it?

----------------------------------------

TWljcm8kb2Z0J3MgIzEgRmFuIQ==
 
I'm not sure exactly but it seems to be a method that I created.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top