Triggering Button clicked event when I hit enter key at edit box....

Discussion in 'ASP .Net' started by Veeresh, Jun 16, 2004.

  1. Veeresh

    Veeresh Guest

    When I enter some data in textbox1 and hit enter key resulting in calling
    the clicked event of Button1. What I am doing wrong here?
    -- Veeresh
    Here is my code.

    <%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm2.aspx.vb"
    Inherits="Test001.WebForm2"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <title>WebForm2</title>
    <meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
    <meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
    <meta name="vs_defaultClientScript" content="JavaScript">
    <meta name="vs_targetSchema"
    content="http://schemas.microsoft.com/intellisense/ie5">
    </HEAD>
    <body MS_POSITIONING="GridLayout">
    <form id="Form1" method="post" runat="server">
    <TABLE id="Table1" style="Z-INDEX: 101; LEFT: 224px; POSITION: absolute;
    TOP: 203px" cellSpacing="1" cellPadding="1" width="300" border="1">
    <TR>
    <TD>
    <asp:TextBox id="TextBox1" tabIndex="1"
    runat="server"></asp:TextBox></TD>
    </TR>
    <TR>
    <TD>
    <asp:TextBox id="TextBox2" tabIndex="2"
    runat="server"></asp:TextBox></TD>
    </TR>
    <TR>
    <TD>
    <asp:Button id="Button1" tabIndex="3" runat="server"
    Text="Button"></asp:Button></TD>
    </TR>
    </TABLE>
    </form>
    </body>
    </HTML>

    and

    Public Class WebForm2

    Inherits System.Web.UI.Page

    Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox

    Protected WithEvents TextBox2 As System.Web.UI.WebControls.TextBox

    Protected WithEvents Button1 As System.Web.UI.WebControls.Button

    #Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.

    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Init

    'CODEGEN: This method call is required by the Web Form Designer

    'Do not modify it using the code editor.

    InitializeComponent()

    End Sub

    #End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load

    'Put user code to initialize the page here

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles Button1.Click

    End Sub

    End Class
     
    Veeresh, Jun 16, 2004
    #1
    1. Advertisements

  2. Steve C. Orr [MVP, MCSD], Jun 16, 2004
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.