[英]What's the difference between SetFocus() and Focus() in ASP.NET?
I can use both in the code behind: 我可以在后面的代码中使用它们:
SetFocus() - "Sets the browser focus to the specified control." SetFocus() - “将浏览器焦点设置为指定的控件。”
Focus() - "Sets input focus to a control." Focus() - “将输入焦点设置为控件。”
In practice, what's the difference? 在实践中,有什么区别?
Thanks! 谢谢!
Page.SetFocus
can accept a control's client ID as a string instead of a reference to the control itself, which may be useful if you can't get a reference to the control to call its Focus method. Page.SetFocus
可以接受控件的客户端ID作为字符串而不是对控件本身的引用,如果您无法获得对控件的引用以调用其Focus方法,则这可能很有用。
control.Focus()
is identical to Page.SetFocus(control)
. control.Focus()
与Page.SetFocus(control)
相同。 In fact, all is does is call SetFocus... 事实上,一切都是调用SetFocus ......
public virtual void Focus()
{
this.Page.SetFocus(this);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.