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

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

Thanks&Regards

Ch.Sukesh Kumar
Posted
Comments
Sergey Alexandrovich Kryukov 6-Jun-12 11:31am    
Why?
--SA

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!
http://www.jacklmoore.com/autosize[^]
and this is the focus document event on jquery website:
api.jquery.com/focus[^]
and this is an example of the script you looking for:
XML
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script>
$(document).ready(function(){
    $('textarea.expand').focus(function () {
        $(this).animate({ height: "1000px" }, 500);
    });
});
</script>
 
Share this answer
 
Comments
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()
{
document.getElementsByName('txtID').type.size="40";
}


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!
Hi,

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

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


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


you can do something like above code,

Thanks
-Amit
 
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