如何使用自动完成扩展器为文本框设置焦点 [英] how to set focus for textbox with autocomplete extender
问题描述
大家好,
我有带ajax自动完整扩展程序的asp控件文本框...
当我通过单击鼠标并在自动完成扩展器中选择项目并按键盘上的Enter键...时,提交按钮不会触发....
有什么问题.任何人都可以解释.
Hi all,
I have asp control textbox with ajax auto complete extender...
when i select item in autocomplete extender with mouse click and i pressed enter button in keyboard....The submit button not fires....
What is the problem..Can anyone explain it.
推荐答案
使用
形式的Defaultbutton 示例:
Use the Defaultbutton Of the form
Example:
<form id="form1" runat="server" defaultbutton="Button1" defaultfocus="TextBox1"><
有关更多信息,请参见此链接
如何为ENTER键按下事件设置默认按钮,以及如何在页面加载时在特定控件上设置焦点,以及如何在按下TAB键时将焦点从一个控件转移到另一个控件 [
For more information refer this link
How To set Default Button for ENTER key pressed event, and How To set Focus on a particular Control when Page loads, and How To Shift Focus from One Control To Another when TAB key is pressed[^]
You can set your button as DefaultButton putting textbox and button in a panel
<asp:Panel ID="Panel1" runat="server" DefaultButton="Button1">
<asp:TextBox runat="server" ID="txtcity" ></asp:TextBox>
<div id="resultDiv" runat="server>
</div>
<cc1:AutoCompleteExtender ID="txtcity_AutoCompleteExtender" runat="server" MinimumPrefixLength="1"
ShowOnlyCurrentWordInCompletionListItem="true" CompletionSetCount="10" ServiceMethod="getcityName"
ServicePath="webservice.asmx" CompletionInterval="1000" CompletionListElementID="resultDiv"
EnableCaching="true" TargetControlID="txtcity">
</cc1:AutoCompleteExtender>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
</asp:Panel>
<pre lang="text">
这篇关于如何使用自动完成扩展器为文本框设置焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!