Reputation: 23
How can I get the value of a textarea using c# ?
my issue is when I using MultiLine TextBox I can't get the full value !! I mean what I wrote including the
breake lines.
ex:
after saving above data it come's in one line 1.Google 2.Microsoft 3.Yahoo
Upvotes: 2
Views: 4216
Reputation: 11
I made this in Visual Basic (easy translation to C#):
Dim convertedtext As String = TextBox1.Text.Replace(Environment.NewLine, "<br />")
and then, I saved convertedtext to the database. TextBox1 is the multiline textbox.
If you enconde the data to show it again (in a literal or similar) do the following:
HttpUtility.HtmlEncode(convertedtext).Replace(HttpUtility.HtmlEncode("<br />"), "<br />")
Upvotes: 1
Reputation: 2167
I'm not 100% sure that I understand the question - but maybe you want to look at the MeasureString method of the graphics class.
Upvotes: 0
Reputation: 42003
the very first result on Google showed me this:
1- I right clicked the TEXTAREA and made it RUN as a Server Control....Its working fine..
2- You can also set the "multiline" property of the standard TextBox control. That control will either render an element or a element, depending on the properties you set. // TextBox1.TextMode = TextBoxMode.MultiLine
Simply create a TextBox
, set TextMode
to MultiLine
, then you can get the text using the .Text
property on your TextBox
object.
It's always worth trying to find the solution for yourself first, then try it out, make mistakes and ask questions. It's the best way to learn.
Upvotes: 1