本文介绍了在C#中按Enter键将焦点移动到网页中的下一个控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
先生/女士
我创建了一个网站,该网站有很多页面,页面有很多控件。
例如我有12个控件3个文本框2 dropdownlistbox 2 chkbox 2 radiobutton 1个按钮..用户想要当他按下回车键焦点将是下一个控件..我发现了一些googly但他们继续前进文本框不在任何其他控件上使用jquery ....
Sir/Madam
I have create a web site that site has many pages and pages are many controls.
for example i have 12 controls 3 textbox 2 dropdownlistbox 2 chkbox 2 radiobutton 1 button .. user wants when he press enter key focus will be to the next control .. i found some googly but they move on textbox not on any other control using jquery....
推荐答案
<asp:textbox runat="server" id="TextBox1" onkeydown="return focusOnNext(event, 'jsTxt2')" xmlns:asp="#unknown"></asp:textbox>
<asp:textbox runat="server" id="TextBox2" onkeydown="return focusOnNext(event, 'jsTxt3')" cssclass="jsTxt2" xmlns:asp="#unknown"></asp:textbox>
<asp:textbox runat="server" id="TextBox3" onkeydown="return focusOnNext(event, 'jsTxt4')" cssclass="jsTxt3" xmlns:asp="#unknown"></asp:textbox>
<asp:textbox runat="server" id="TextBox4" cssclass="jsTxt4" onkeydown="return focusOnNext(event, 'jsDDL1')" xmlns:asp="#unknown"></asp:textbox>
<asp:dropdownlist runat="server" id="DropDownList1" cssclass="jsDDL1" onkeydown="return focusOnNext(event, 'jsCHK1')" xmlns:asp="#unknown">
<asp:listitem text="Text1" value="Value1"></asp:listitem>
<asp:listitem text="Text2" value="Value2"></asp:listitem>
</asp:dropdownlist>
<asp:checkbox runat="server" id="CheckBox1" cssclass="jsCHK1" text="Checkbox" xmlns:asp="#unknown" />
function focusOnNext(e, nextControl) {
alert(e.keyCode);
if (e.keyCode == 13) {
如果有帮助请告诉我。
Azee ......
Let me know if it helps.
Azee...
这篇关于在C#中按Enter键将焦点移动到网页中的下一个控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!