在ASP.Net的服务器端将焦点设置为文本框的结尾 [英] Set focus to end of textbox in server side in ASP.Net

查看:57
本文介绍了在ASP.Net的服务器端将焦点设置为文本框的结尾的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我有一个文本框,它的TextMode ="MultiLine".我希望在刷新页面时将焦点设置在此文本框的末尾.
换句话说,我希望焦点始终设置在文本框的末尾.
thnx

Hi I have a textbox and it''s TextMode="MultiLine". I want set focus to end of this textbox when the page is refreshed.
In other way I want that the focus always sets in the end of the textbox.
thnx

推荐答案

将焦点设置到TextBox的末端"与将焦点设置在TextBox的任何其他位置"完全相同. .焦点的概念表示键盘的焦点,并且仅与控件有关.不要混淆重点和选择.

虽然可以使用方法System.Web.UI.WebControls.TextBox.Focus,但是不能使用此控件控制文本选择.这在WPF和System.Windows.Forms中是可能的,而在APS.NET中则不是.

请参阅 http://msdn.microsoft.com/en-us/library /system.web.ui.webcontrols.textbox.aspx [ ^ ].

—SA
"Setting the focus to the end side of TextBox" is the exactly same thing as "setting the focus in any other place of TextBox". The notion of focus means keyboard focus and is related only to the control. Don''t mix up focus and selection.

While you can use the method System.Web.UI.WebControls.TextBox.Focus, you cannot control text selection using this control. This is possible in WPF and System.Windows.Forms, not in APS.NET.

See http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.textbox.aspx[^].

—SA


您可以通过一些简单的Javascript做到这一点-参见^ ].
You can do this via some simple Javascript - see here[^].


,您可以使用Textarea代替TextBox,并可以使用javascrip
实现此功能.
看看 javascript获取并设置textarea中的插入符位置/ [ ^ ]
instead of TextBox you can use Textarea and can achieve this functionality using javascrip

Have a look on that javascript getting and setting caret position in textarea/[^]


这篇关于在ASP.Net的服务器端将焦点设置为文本框的结尾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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