Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Text cut in text area in ASP.net page

Tags:

html

c#

asp.net

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 text field not appear well

the orginal text is "ECASTI (Egyptian Center for the Advancement of Science, Technology, and Innovation) "

can any one help ??!!!

like image 660
Bassam Abdeltwab Avatar asked Jan 02 '15 18:01

Bassam Abdeltwab


3 Answers

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;
like image 53
sandipon Avatar answered Nov 09 '22 12:11

sandipon


Dont fix the height of textbox. Height should be auto.And in css add property for textbox. It will work.

    word-wrap: break-word;
like image 29
Shariq Ansari Avatar answered Nov 09 '22 11:11

Shariq Ansari


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;
    }
like image 27
Ali Vojdanian Avatar answered Nov 09 '22 11:11

Ali Vojdanian