hi i want that textbox's height should be increased based on its content
textbox is multiline and its width i have put fixed.. n i dont want to show verticle scrollbar.
how to increase its height as its content increased
just like this way :

Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Amit ChoudharyPosted Mar 3, 2010, 2:20 AM
you can use following plugin of Jquery for this purpose:
http://plugins.jquery.com/project/autogrow
Note: Take care of class names and id of control while using this plugin.
Don't forget to mark as answer.
Arun KumarPosted Apr 5, 2013, 6:44 AM
Hai Please check the link also
http://blogs.sitepointstatic.com/examples/tech/textarea-expander/index.html
Arun KumarPosted Apr 5, 2013, 6:39 AM
http://www.jacklmoore.com/autosize/
Arun KumarPosted Apr 5, 2013, 2:45 AM
This is arun kumar from India. I am also looking for the same like what dipa ahuja faced. I used your javascript. When i keyed some mesages it is extended automatically. but when i cleared it, it shows the extended textarea.
I need it like facebook comments input.
Thanks in advance...
Dipa AhujaPosted Mar 5, 2010, 12:51 PM
thanx
Amit ChoudharyPosted Mar 5, 2010, 7:48 AM
you should mark my answer because your first problem is solved .
and now its your second issue that coming....
i suggest you to add label control and a Text Box control... when you click on update set TextBox to visible and Hide the Label when you click on
update then hide the TextBox and show the Label control.
also put the lable inside a div give a proper css style with a border to give the look of inactive TextBox.
Thats it.
Now Please mark all answers cause it help me to get some points.
Dipa AhujaPosted Mar 5, 2010, 6:35 AM
it is like orkut profile status.. butt when i click on update it shows the textbox with verticle scrollbar.
Amit ChoudharyPosted Mar 4, 2010, 11:54 PM
here is tha javascript code:
// Value of the line-height CSS property for the textarea.
var TEXTAREA_LINE_HEIGHT = 13;
function grow() {
var textarea = document.getElementById('TextBox1');
var newHeight = textarea.scrollHeight;
var currentHeight = textarea.clientHeight;
if (newHeight > currentHeight) {
textarea.style.height = newHeight + 5 * TEXTAREA_LINE_HEIGHT + 'px';
}
}
OnTextChanged="TextBox1_TextChanged" ReadOnly="True"
Font-Size="Medium" ForeColor="#333399"
onkeyup="grow();" CssClass="txt" />
use this code. i have changed the id in java script function
var textarea = document.getElementById('TextBox1');
and it works fine m already tried it and it works great.
Dipa AhujaPosted Mar 4, 2010, 7:56 AM
OnTextChanged="TextBox1_TextChanged" ReadOnly="True"
Font-Size="Medium" ForeColor="#333399"
onkeyup="grow();" CssClass="txt" />
.cs
protected void Button1_Click(object sender, EventArgs e)
{
if (Button1.Text == "Edit")
{
TextBox1.ReadOnly = false;
TextBox1.Text.Replace("\n", "
");
TextBox1.BackColor = System.Drawing.Color.Gray;
Button1.Text = "Update";
}
else if (Button1.Text == "Update")
{
TextBox1.ReadOnly = true;
TextBox1.BackColor = System.Drawing.Color.White;
objcon.Open();
SqlCommand comm = new SqlCommand("Update profile set status=@status where profileId=@profileId", objcon);
comm.Parameters.AddWithValue("@status", TextBox1.Text.ToString());
comm.Parameters.AddWithValue("profileId", p.profile_Id);
comm.ExecuteNonQuery();
objcon.Close();
p.status = TextBox1.Text;
Button1.Text = "Edit";
}
}
when i click on button first time(means when textbox "readonly=false" and we can enter text in it" the text dosnt show vertical scrollbar means working bt when i click on button to update the textbox it shows verticle scrollbars
Amit ChoudharyPosted Mar 4, 2010, 12:35 AM
Well jquery solution is not working good as it is having some bugs still....
so i have found another solution using simple javascript. I'm uploading the project and its working fine.
and Don't forget to mark as answer.
Amit ChoudharyPosted Mar 3, 2010, 8:44 AM
Dipa AhujaPosted Mar 3, 2010, 6:25 AM
i tried what you wrote bt its not working,
to Amit
i dont have knowledge about jquery n i have never used it wo would you plz give me jz one example how i have to use it?
Raaj KumarPosted Mar 3, 2010, 1:53 AM
Try this code,