473,387 Members | 1,579 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

scrolling to bottom of textbox in asp.net? (ie, javascript)

I have a textbox that i am adding to (in codebehind of ASP.NET) and
need to ensure that the focus is scrolled to the bottom of the textbox
each time the page refreshes, and then set focus to a 2nd textbox
(which the user types input into).

I have tried a couple functions I found posted online but they don't
work (see below)

The closest I got was using the scrolldown method:

http://msdn.microsoft.com/library/default.asp?
url=/workshop/author/dhtml/reference/methods/doscroll.asp

but this only scrolls down at most 1 page. How do I scroll to the
absolute bottom no matter how much text is in the box?

Thanks

in Head:

<script type="text/javascript">
function focusById(elemid)
{
elem = document.getElementById(elemid);
if(elem)
{
elem.focus();
MoveToEnd(elem);
elem.focus();
}
}

function MoveToEnd(Element)
{
if ( Element.createTextRange )
Element.createTextRange().text += "";
else if ( Element.insertionPoint )
Element.insertionPoint = Element.text.length;
}

</script>
</HEAD>
In onload (various versions, #6 sort of worked):
// SCROLL TO BOTTOM OF TEXTBOX #1 AND SET FOCUS ON TEXTBOX #2

//ATTEMPT #1
focusById(document.Form1.Textbox1);
document.Form1.Textbox2.focus();

//ATTEMPT #2
var sText=document.Form1.Textbox1.value;
document.Form1.Textbox1.value=sText;
document.Form1.Textbox2.focus();

//ATTEMPT #3
document.Form1.Textbox1.focus();
document.Form1.Textbox1.MoveToEnd(elem);
document.Form1.Textbox1.elem.focus();
document.Form1.Textbox2.focus();

//ATTEMPT #4
document.Form1.Textbox1.focus();
document.Form1.Textbox1.MoveToEnd(elem);
document.Form1.Textbox1.elem.focus();
document.Form1.Textbox1.doScroll();
document.Form1.Textbox2.focus();

//ATTEMPT #5
MoveToEnd(document.Form1.Textbox1);
document.Form1.Textbox2.focus();

//ATTEMPT #6
//seemed to work but only scrolls down a little
//how do i scroll to the absolute end
//no matter how much text is in Textbox1 ?
MoveToEnd(document.Form1.Textbox1);
document.Form1.Textbox1.doScroll('down');
document.Form1.Textbox2.focus();

//ATTEMPT #7
document.Form1.Textbox1.doScroll('down');
document.Form1.Textbox2.focus()

Nov 19 '05 #1
0 2698

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Julie Siebel | last post by:
Apologies...I'm sure this has been asked before, but I can't seem to come up with the correct Google search terms. While my problem is with stylesheets, the errors are being caused by my...
2
by: Mike Walker | last post by:
Hi, Please can you help me, I have seen some free JavaScript that has a text box, with buttons under it Bold, Italic, Underline, so when the text in the box is highlighted, it puts the HTML code...
4
by: headware | last post by:
I have a <select> control that contains many entries. It allows the user to multi-select a group of them, click a button, and store the selected data in a database. Normally they do this starting...
3
by: webguru | last post by:
I am trying to be able to pass a parameter in my URL to a subpage that will load the file specified in the paramater into an IFRAME. I have hardly used Javascript, and am trying to figure out how...
0
by: Phillip Ian | last post by:
I have a textbox that I'm trying to limit to numeric entry (damn you Microsoft for not including it in .NET!) I've found sample code and come up with this as a solution: <asp:TextBox...
5
by: Kent Briggs | last post by:
VB 2005 Express. I have a readonly multiline textbox with a vertical scrollbar. I'm programatically adding text to it with textbox1.appendtext(mytext) and it scrolls automatically. However, I only...
1
by: seadog | last post by:
Hi, I am having a problem displaying data in a textbox array. What I am trying to do is have 5 number enter 5 textboxes, starting from the first and working there way to the bottom textbox. What...
1
by: sven2000 | last post by:
Is there a way to either - know when the user has scrolled - turn of 'smooth' scrolling (so a scoll is line by line) What I want to do is to insert the cursor at a specific row and colum after...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.