i'm trying to load text from database into many text fields every thing is Ok , but one field of them text lenght is more than the length of the text field so not all the text appear on the screen that is my ASP.net code
<asp:TextBox ID="descriptiont" runat="server" Rows="3" Width="300px" Height="100px" Wrap="true">
and that is the code behind of it
descriptiont.Text = s.GetValue(1).ToString();
descriptiont.Enabled = false;
and that is what i get in the web page
the orginal text is "ECASTI (Egyptian Center for the Advancement of Science, Technology, and Innovation) "
can any one help ??!!!
use this:
<asp:TextBox id="TextArea1" TextMode="multiline" Columns="50" Rows="5" runat="server" />
Then you can access the content via:
string message= TextArea1.Text;
Dont fix the height of textbox. Height should be auto.And in css add property for textbox. It will work.
word-wrap: break-word;
Try this :
string s = "Your Text Field";
if (s.Length > 20)
{
//Change Width="450px"
}
Update :
You can aslo change width in CSS when text length is more than the length of the field.
Update 2 :
You can resize the textbox in C# with the following codes :
if (s.Length>20)
{
textBox1.TextChanged += textBox1_TextChanged;
}
void textBox1_TextChanged(object sender, EventArgs e)
{
Size size = TextRenderer.MeasureText(textBox1.Text, textBox1.Font);
textBox1.Width = size.Width;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With