Click here to Skip to main content
16,004,806 members
Please Sign up or sign in to vote.
1.20/5 (2 votes)
See more:
Please help me to call this JS in a TextBox text changed event
HTML
<script type="text/javascript">
Sys.Application.add_load(function() {
var t = document.getElementById('scrollable-content');
t.scrollTop = t.scrollHeight;
});
</script>
Posted
Updated 27-May-13 1:58am
v2
Comments
Sunasara Imdadhusen 27-May-13 8:00am    
try..<input type="text" önchange="Sys.Application.add_load();" />

I am making the assumption that you know how to load jquery/where to get jquery. But below are two options...a "javascript" way (on change) and a jquery method of doing what you are asking (or what i think you are asking).

XML
1) Using Jquery

<script type="text/javascript">
    $("#textbox").keyup(function(){
        var t = document.getElementById('scrollable-content');
        t.scrollTop = t.scrollHeight;
    });
</script>


<div id="scrollable-content">

</div>

<input type="text" id="textbox" />


2) Using javascript

<script type="text/javascript">
    Sys.Application.add_load(function() {
        var t = document.getElementById('scrollable-content');
        t.scrollTop = t.scrollHeight;
    });
</script>


<div id="scrollable-content">

</div>

<input type="text" onchange="Sys.Application.add_load" />
 
Share this answer
 
Comments
Athulk 28-May-13 0:22am    
Thanks, but i have a different issue. I have a textbox(txtMessage). whatever i type there is displayed on a dynamic label which is on an update panel which is on a scrolling div

scrolling div
update panel
dynamic label

that way.

My problem is the srolling div must come down when txtmessage is clicked.
i gotta js code for that which in postback will come down, but though its an update panel, it wil go down always ehen the panel updates.

Pleas help
This applies, only if your textbox is asp.net textbox, if so then:

assume this is your text box in .aspx:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

then just wrap your js code into a js function like below:
XML
<script type="text/javascript">
function changeHeight() {
var t = document.getElementById('scrollable-content');
t.scrollTop = t.scrollHeight;
}
</script>

Make sure to add this script part under your page's heade section...
then go to your asp.net page's page_load event in code behind side and add code like this:
C#
if(!Page.IsPostBack)
TextBox1.Attributes.Add("onchange", "javascript:changeHeight();");

done, build and run your app and let me know if this is what you wanted to do...
 
Share this answer
 
Hi,

Simple

<asp:TextBox ID="TextBox1" onchange="javascript:alert('put your javascript here...'); runat="server"></asp:TextBox>"
 
Share this answer
 
v2

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