Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help using javascript and asp.net to get cursor position 1

Status
Not open for further replies.

aspdotnetuser

Programmer
Oct 10, 2008
45
0
0
GB
Hi,

I have looked on the net but there aren't any examples which explain how to get the current cursor position in a textbox and pass it to an inline asp.net method. Can someone who knows how to do this provide some example code? Or some suggestions? Thanks :)
 
You will have to use javascript to get the value. There are a number of examples online. This thread looks like it has some good info ...


There are lots of different ways to pass values between .net and javascript, but the best method depends entirely on what you plan to do with the info and how you want the page to work.

If you give us a little more detail on how the page will work we might be able to point you in the right direction. In the meantime google 'asp.net and javascript' and have a look at this article...

 
Thanks for the links th3maw, their useful especially the msdn url which I hadn't come accross.

I have a multiline text box which displays text from a text file the user has selected from a drop down menu. The text is saved and can then be selected to be sent in an email. (the text files are email templates) But because newlines aren't output in the email I want to provide buttons the user can click to insert newlines and other html tags at the current position of the cursor.

So I need a javascript function that gets the current position of the cursor in the textbox and inserts the newline html tag.
 
I decided to allow users to enter html tags, thanks for the links.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top