获取文本框内容中的光标位置 [英] Get cursor position in a textbox content

查看:55
本文介绍了获取文本框内容中的光标位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我需要在asp文本框内容中获取光标位置。

请给我你的建议。 />


谢谢,

Hi,

I need to get a cursor location in a asp textbox content.
Please give me your suggestions.

Thanks,

推荐答案

试试myTextBox.SelectionStart。你应该到达插入符号的地方







我刚刚意识到你在说话关于asp.net。我认为你应该使用javascript,请参考如何使用javascript从文本框控件中获取所选文本
Try myTextBox.SelectionStart . You should get where the caret is



I've just realized you were talking about asp.net. I think you should use javascript for that, refer this How to get selected text from textbox control with javascript


您可以使用TextBox控件的属性SelectionStart。请注意,无论是否选择了文本,您都可以使用此属性来查找光标的位置。



有关此方法的完整详细信息此处 [ ^ ]。
You can use the property SelectionStart of the TextBox Control. Note that whether the text is selected or not you can use this property to find the position of the cursor.

Full details about this method available here[^].


这篇关于获取文本框内容中的光标位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆