Click here to Skip to main content
15,921,643 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

When i click on the textbox the size of texbox should be increase.. can any one please help on this issue?


Ch.Sukesh Kumar
Sergey Alexandrovich Kryukov 6-Jun-12 11:31am    

you can you jquery focus function , that when mouse move to your textbox and click this method fire!
this link work better than your Idea,when the character length go bigger the size increase![^]
and this is the focus document event on jquery website:[^]
and this is an example of the script you looking for:
<script type="text/javascript" src=""></script>
    $('textarea.expand').focus(function () {
        $(this).animate({ height: "1000px" }, 500);
Share this answer
Member 8652316 6-Jun-12 9:30am    
thanks for reply i don't know how to use jquery in textbox click event, Please let me know once..
taha bahraminezhad Jooneghani 6-Jun-12 10:32am    
just set the ID of your text box to the line 1!
and my first link is very complete and have a good step by step!
Member 8652316 6-Jun-12 10:55am    
hmm.. Thank you very much. its working fine

One more request when i click on textbox it should automatically increase the size(height) with out enter any text in textbox.. Is it possible?
Member 8652316 6-Jun-12 11:01am    
I did some javascript but by using this i able to increase width but not height in click event of textbox. please have a look on the code

&<script type="text/javascript">
function Increase_Size()

i called this function in textbox onclick event..
taha bahraminezhad Jooneghani 6-Jun-12 11:34am    
try this:
document.getElementsByName('txtID').width = "100px";
if correct accept my solution!

you can use Javascript to increase size of textbox on click event like,

Your c# code :
TextBox1.Attributes["onclick"] = "clearTextBox(";

Your Javascript Code :
function clearTextBox(textBoxID)
    var someTextBox = document.getElementById("textBoxID");
    var currentWidth =["width"]; 
    //// now you need to increase currentWidth by 1 to and set it again to textbox.

you can do something like above code,

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900