重点转移到地址 [英] Focus Jumps to Address

查看:57
本文介绍了重点转移到地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究ASP.NET 2.0(VB)Web应用程序.我无法控制制表符行为.

TabIndex已在整个表单和选项卡中按预期设置.

但是,在更改文本框并单击"Tab"或"Enter"后,焦点将跳转到网址栏,而不是下一个字段.

我试过了:
1.SetFocus上的文字更改事件
2.在隐藏的文本框中保存最后一个字段名称,并将焦点设置为如果回发后在页面加载上保存的文本框名称
3.SetFocus on Pre_render

尽管如此,焦点仍跳到选项卡上的浏览器地址栏或输入.

我认为它可能会丢失回发后的Tab索引.

有任何线索吗?

在此先感谢您的帮助.

解决方案

浏览器地址栏不是HTML的一部分.因此,无法编写将焦点从页面设置到条形的代码.通常,如果可以的话,我通常会尝试使用AJAX,并且我会尝试在页面中放置一些javascript,以便在页面加载时,它可以设置您想要的焦点,而不是信任后面的代码来为您完成操作. /blockquote>



可以使用某些html标签上的tabindex属性来控制制表符顺序.看这个例子:

 <   html  > ; 
<  头部 > 
  <  标题 >  TAB顺序测试<  /title  > 
<  /head  > 
<  正文 > 
  <  表单 > 
    文字1(第一个标签):
    <  输入    ="  文本" 名称   txt1"    tabindex   =   1  / >   br  / > 
    文字2(第三个标签):
    <  输入    ="  文本" 名称   txt2"    tabindex   =   3  / >   br  / > 
    Text3(第四个标签):
    <  输入    ="  文本" 名称   txt3"    tabindex   =   4  / >   br  / > 
    文字4(第二个标签):
    <  输入    ="  文本" 名称   txt4"    tabindex   =   2  / >   br  / > 
  <  /form  > 
<  /body  > 
<  /html  >  <  /html  >  


支持的标签包括a,textarea,选择和输入类型...
如果要跳过控制,则将其tabindex设置为0(tabindex = 0).

还有一个有用的链接.看起来 http://www.dotnetcurry.com/ShowArticle.aspx?ID=253 [ ^ ]

正是我所需要的!


I am working on an ASP.NET 2.0 (VB) web application. I am having trouble controlling tab behavior.

TabIndex is set throughout the form and tabs as expected.

But,after making a change in a textbox and hitting Tab or Enter, the focus jumps to the web address bar instead of the next field.

I have tried:
1.SetFocus on the text change event
2.Saving last field name in a hidden textbox and set focus to saved textbox name on Page Load if Post back
3.SetFocus on Pre_render

Still, focus jumps to browser address bar on tab or enter.

I think it may be losing the tab index on post-back.

Any clues?

Thanks in advance, any help is appreciated

解决方案

The browser address bar is not part of your HTML. As such, it''s not possible to write code that sets the focus from the page to the bar. I would in general try to move to AJAX if I could, and I would try to put some javascript in the page so that on page load, it sets the focus you want, instead of trusting the code behind to do it for you.


Hi,

Tab order can be controled with tabindex property on some html tags. Look thi example:

<html>
<head>
  <title>TAB Order test</title>
</head>
<body>
  <form>
    Text1 (first tab):
    <input type="text" name="txt1" tabindex=1 /><br />
    Text2 (third tab):
    <input type="text" name="txt2" tabindex=3 /><br />
    Text3 (fourth tab):
    <input type="text" name="txt3" tabindex=4 /><br />
    Text4 (second tab):
    <input type="text" name="txt4" tabindex=2 /><br />
  </form>
</body>
</html></html>


Suported tags are a, textarea, select and input types...
If you want to skip control then set its tabindex to 0 (tabindex=0).

One more link that can be useful. Look control your tab order and cursor focus [^]. ;)


Found this:

Shift Focus to the Next Control during a PostBack using ASP.NET and LINQ
http://www.dotnetcurry.com/ShowArticle.aspx?ID=253[^]

It was exactly what I needed!


这篇关于重点转移到地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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