Control.Focus Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Sets input focus to a control.
public:
virtual void Focus();
public virtual void Focus ();
abstract member Focus : unit -> unit
override this.Focus : unit -> unit
Public Overridable Sub Focus ()
Remarks
Use the Focus method to set the initial focus of the Web page to the control. The page will be opened in the browser with the control selected.
The Focus method causes a call to the page focus script to be emitted on the rendered page. If the page does not contain a control with an HTML ID
attribute that matches the control that the Focus method was invoked on, then page focus will not be set. An example where this can occur is when you set the focus on a user control instead of setting the focus on a child control of the user control. In this scenario, you can use the FindControl method to find the child control of the user control and invoke its Focus method.
Applies to
See also
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈