使用选项卡时处理控制焦点 [英] Handle control focus while use tab
本文介绍了使用选项卡时处理控制焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨朋友们,
如何在点击标签时处理控制焦点。在我的表单中,当我点击一个标签时,有时焦点会转到母版页标识。我有接下来的行中的文本框控件列表。
我在每个控件中都使用了TabIndex属性。但是,没用。请建议我任何解决方案。非常感谢您的帮助。谢谢你提前。
Hi friends ,
How to handle control focus on when click tab. In my form when i am clicked a tab , sometimes the focus gone to the master page logo. I have list of textbox controls in next next rows.
I used TabIndex property also in each control. But , no use. Please suggests me any solution. Your help will be appreciate very much. Thanks for advance.
推荐答案
嗨朋友们,
我已经解决了上述问题。在那种情况下,在某些情况下会发生回发。这是我的TabIndex属性为什么不起作用的唯一原因?现在,我的TabIndex工作正常。另外,我在回发发生后添加了一些控制焦点。以下代码是我在聚焦后使用的。
Hi friends ,
I have resolved myself in above question. I that case , the postback is occurred in some cases. This is the only reason my TabIndex property why was not work ? now , My TabIndex working properly. Additionally , I am add some control focus after postback was occurred. The following code was i am used after focusing.
if (IsPostBack)
{
Control ctrl = GetControlThatCausedPostBack(this.Page);
if (ctrl != null)
ctrl.Focus();
}
/// <summary>
/// Retrieves the control that caused the postback.
/// </summary>
/// <param name="page"></param>
/// <returns></returns>
private Control GetControlThatCausedPostBack(Page page)
{
//initialize a control and set it to null
Control ctrl = null;
//get the event target name and find the control
string ctrlName = page.Request.Params.Get("__EVENTTARGET");
if (!String.IsNullOrEmpty(ctrlName))
ctrl = page.FindControl(ctrlName);
//return the control to the calling method
return ctrl;
}
感谢您的所有宝贵意见..
Thanks for all of your valuable comments..
这篇关于使用选项卡时处理控制焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文