我想防止ASP.NET GridView对输入按钮做出反应 [英] I want to prevent ASP.NET GridView from reacting to the enter button
问题描述
我有一个带有网格视图控件的ASP.NET页,其中的CommandButton列具有删除和选择命令.
I have an ASP.NET page with a gridview control on it with a CommandButton column with delete and select commands active.
按下Enter键将触发gridview中的第一个命令按钮,从而删除一行.我不希望这种情况发生.我可以更改gridview控件,使其不再对按Enter键做出反应吗?
Pressing the enter key causes the first command button in the gridview to fire, which deletes a row. I don't want this to happen. Can I change the gridview control in a way that it does not react anymore to pressing the enter key?
屏幕上也有一个文本框和按钮.他们不需要对按Enter做出响应,但是您必须能够填写文本框.当前,我们弹出一个确认对话框以防止意外删除,但是我们需要的比这更好的东西.
There is a textbox and button on the screen as well. They don't need to be responsive to hitting enter, but you must be able to fill in the textbox. Currently we popup a confirmation dialog to prevent accidental deletes, but we need something better than this.
这是gridview的标记,如您所见,它位于asp.net updatepanel内部(抱歉,我忘了提一下):(我遗漏了大多数列和格式)
This is the markup for the gridview, as you can see it's inside an asp.net updatepanel (i forgot to mention that, sorry): (I left out most columns and the formatting)
<asp:UpdatePanel ID="upContent" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnFilter" />
<asp:AsyncPostBackTrigger ControlID="btnEdit" EventName="Click" />
</Triggers>
<ContentTemplate>
<div id="CodeGrid" class="Grid">
<asp:GridView ID="dgCode" runat="server">
<Columns>
<asp:CommandField SelectImageUrl="~/Images/Select.GIF"
ShowSelectButton="True"
ButtonType="Image"
CancelText=""
EditText=""
InsertText=""
NewText=""
UpdateText=""
DeleteImageUrl="~/Images/Delete.GIF"
ShowDeleteButton="True" />
<asp:BoundField DataField="Id" HeaderText="ID" Visible="False" />
</Columns>
</asp:GridView>
</div>
</ContentTemplate>
</asp:UpdatePanel>
推荐答案
此解决方案阻止了整个页面上的Enter键
This solution is blocking the enter key on the entire page
这篇关于我想防止ASP.NET GridView对输入按钮做出反应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!