473,396 Members | 1,847 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,396 software developers and data experts.

How to get cursor insertion point (caret position) from text box

Can anybody help me to a)get the user's cursor insertion point (caret)
from a multiline textbox, using client-side script I suppose, and then
b)return the position to VB code behind?

I have tried the following client-side function suggested on this
Google Group (thank you) but I'm not sure what it's doing or how to
return the caret position to code behind ("txtReading" is the Textbox
ID):

function getcaretpos(txtReading)
{
if (txtReading.createTextRange)
txtReading.caretPos =
document.selection.createRange().duplicate();
}
Nov 18 '05 #1
2 6750
I don't know much about a). To solve b) you can add a hidden <input> element
in the form. It is accessible both on server and client. Set the value to
the cursor position on client and read it on server in code-behind.

Eliyahu

"DaveR" <da**@bluehills.co.uk> wrote in message
news:1c**************************@posting.google.c om...
Can anybody help me to a)get the user's cursor insertion point (caret)
from a multiline textbox, using client-side script I suppose, and then
b)return the position to VB code behind?

I have tried the following client-side function suggested on this
Google Group (thank you) but I'm not sure what it's doing or how to
return the caret position to code behind ("txtReading" is the Textbox
ID):

function getcaretpos(txtReading)
{
if (txtReading.createTextRange)
txtReading.caretPos =
document.selection.createRange().duplicate();
}

Nov 18 '05 #2
Eliyahu - thanks for that - good idea - I assume this would also work
with a hidden Webcontrol Textbox? Now, does anybody know how to get the
caret position and place it in the hidden <input> element (or Textbox)?


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #3

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

Similar topics

2
by: Bambam6235 | last post by:
Hi all, I would like to determine where the current insertion point is in a text field. Say I had a text field that held 80 characters. I would like to display to the user the current...
1
by: Barry | last post by:
Retoring Caret Position after text field correction -------------------------------------------------------------------------------- Hi, my code has the following form - function...
4
by: torch | last post by:
I have trawled the internet for a solution to this one . All I need is the caret position as a number. I have seen quite a few text insertion functions that do something like this : ...
4
by: cc | last post by:
Hi, Is possible set and get the caret position of cursor in a text field ? Thanks, Carlo
3
by: (Pete Cresswell) | last post by:
I've got this DoCmd in a fields Change() event so that as the user types, the underlying table (also visible in another screen...) will be updated in realtime - instead of waiting for the screen TB...
3
by: Klaus Brune | last post by:
Hello all, When one tabs through a form (specifically, in Firefox), all the text in a field is automatically selected. What I'm looking for is a way to put a function (in onFocus perhaps)...
0
Jezternz
by: Jezternz | last post by:
Okay, so a while back I managed to retrieve it correctly. In this thread: http://bytes.com/topic/javascript/answers/786211-retrieving-caret-start-end-values#post3127765 However I have found...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.