Textfield问题 - Enter按钮触发注销按钮 [英] Textfield problem - Enter button fires the logout button

查看:69
本文介绍了Textfield问题 - Enter按钮触发注销按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我对使用VS进行编程相当陌生,我的道歉。

I am fairly new to programming with VS, my apologies.

我有一个文本字段用户将键入部分或全部要搜索的姓氏。当我将此页面放在服务器上并测试文本字段时,按下键盘上的enter键会激活页面上的注销按钮。

I have a textfield where the user will type part or all of a last name to search. When I put this page on the server and tested the textfield, hitting enter on the keyboard activated the logout button on the page.

所以,我在TF上添加了一个onLoad,以便我可以尝试设置焦点。仍然没有奏效。在同一个onLoad处理程序中,我添加了一个Response.Write。这似乎有效,但我需要知道原因。

So, I added an onLoad to the TF so that I could try to set focus. Still didn't work. In the same onLoad handler I added a Response.Write. That seems to work but I need to know why.

任何帮助都将不胜感激。

Any help would be appreciated.

/ ****以下代码仅供参考。片段  ****** /

/**** The code below is only a fragment.  ******/

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

    private void Form1_Load(object sender, System.EventArgs e)
    {
        Response.Write("I AM");
        TextBox1.Focus();
    }
</script>


<form id="form1" runat="server" defaultfocus="TextBox1">
    <asp:Button ID="SignOut" TabIndex="2" runat="server" Text="Log Out" OnClick="Signout_Click" />
    <br />      

                <table style="width: 1080px" border="0" cellpadding="0" cellspacing="1" class="GridviewTable">
                                              
                        <tr>
                            <td style="width: 130px;">
                            </td>
                            <td style="width: 170px;">
                               <!-- Last Name -->
                                <asp:TextBox ID="TextBox1" TabIndex="1" runat="server" Value="%" 
                                    onload="Form1_Load"></asp:TextBox>
                                
                            </td>




推荐答案

请发布ASP.NET ASP.NET论坛中的问题( http://forums.asp.net )。
Please post ASP.NET questions in the ASP.NET forums (http://forums.asp.net ).


这篇关于Textfield问题 - Enter按钮触发注销按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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