Enter key to invoke button event handler?

Discussion in 'ASP .Net' started by Olav Tollefsen, Jan 18, 2004.

  1. I have created a client side script that is supposed to invoke the Click
    event handler on a button. The problem is that it doesn't work. Instead the
    page is refreshed an Page_Load is invoked, but not my event handler. The
    source of my .aspx page is included below.

    What could the problem be?

    Olav

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>
    <title>Adressesøk</title>
    <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
    <meta content="C#" name="CODE_LANGUAGE">
    <meta content="JavaScript" name="vs_defaultClientScript">
    <meta content="http://schemas.microsoft.com/intellisense/ie5"
    name="vs_targetSchema">
    <LINK href="CSS/Level1_Verdana.css" type="text/css" rel="stylesheet">
    <script language="javascript">
    function CheckEnterKey()
    {
    if (event.keyCode == 13)
    {
    event.cancelBubble = true;
    event.returnValue = false;
    document.all["SearchButton"].click();
    }
    }
    </script>
    </HEAD>
    <body>
    <form name="Form1" method="post" action="FindAddress.aspx" id="Form1">
    <input type="hidden" name="__VIEWSTATE"
    value="dDwxMTc0MDkyNjQyOztsPFNlYXJjaEJ1dHRvbjs+PnBboIsL2pjTbk7MQyuNJ1UOHcfr"
    />

    <table cellSpacing="0" cellPadding="0" width="785" border="0">
    <tr>
    <td><IMG height="132" src="Images/Top.jpg" width="785"></td>
    </tr>
    <tr>
    <td>
    <table cellSpacing="0" cellPadding="0" width="785" border="0">
    <tr>
    <td vAlign="top" width="160"
    background="Images/LeftBackground2.gif">
    <table cellSpacing="0" cellPadding="0" width="160" border="0">
    <tr>
    <td background="Images/LeftBackground1.gif"
    height="431">&nbsp;</td>
    </tr>
    </table>
    </td>
    <td vAlign="top" bgColor="#e9e9e9">
    <table cellSpacing="0" cellPadding="1" width="100%" border="0">
    <tr>
    <td width="5">&nbsp;</td>
    <td><br>
    <H2>Adressesøk</H2>
    <P><input name="SearchText" type="text" value="Kvennberggata"
    id="SearchText" />&nbsp;
    <input type="image" name="SearchButton" id="SearchButton"
    src="Images/SearchButton.gif" border="0" /></P>
    <P>
    <div id="Panel1">



    <br>

    </div>

    </P>
    <P></P>
    </td>
    <td width="5">&nbsp;</td>
    </tr>
    </table>
    </td>
    <TD vAlign="top" width="1" bgColor="#212148"></TD>
    </tr>
    </table>
    </td>
    </tr>
    <tr>
    <td bgColor="#212148">&nbsp;</td>
    </tr>
    </table>
    <SCRIPT
    language="javascript">document.getElementById('SearchText').focus()</SCRIPT>

    </form>
    </body>
    </HTML>
     
    Olav Tollefsen, Jan 18, 2004
    #1
    1. Advertising

  2. Olav Tollefsen

    Alvin Bruney Guest

    Have you figured this out, or at least a work around?

    --
    Regards,
    Alvin Bruney [ASP.NET MVP]
    Got tidbits? Get it here...
    http://tinyurl.com/3he3b
    "Olav Tollefsen" <> wrote in message
    news:%...
    > I have created a client side script that is supposed to invoke the Click
    > event handler on a button. The problem is that it doesn't work. Instead

    the
    > page is refreshed an Page_Load is invoked, but not my event handler. The
    > source of my .aspx page is included below.
    >
    > What could the problem be?
    >
    > Olav
    >
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    > <HTML>
    > <HEAD>
    > <title>Adressesøk</title>
    > <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
    > <meta content="C#" name="CODE_LANGUAGE">
    > <meta content="JavaScript" name="vs_defaultClientScript">
    > <meta content="http://schemas.microsoft.com/intellisense/ie5"
    > name="vs_targetSchema">
    > <LINK href="CSS/Level1_Verdana.css" type="text/css" rel="stylesheet">
    > <script language="javascript">
    > function CheckEnterKey()
    > {
    > if (event.keyCode == 13)
    > {
    > event.cancelBubble = true;
    > event.returnValue = false;
    > document.all["SearchButton"].click();
    > }
    > }
    > </script>
    > </HEAD>
    > <body>
    > <form name="Form1" method="post" action="FindAddress.aspx" id="Form1">
    > <input type="hidden" name="__VIEWSTATE"
    >

    value="dDwxMTc0MDkyNjQyOztsPFNlYXJjaEJ1dHRvbjs+PnBboIsL2pjTbk7MQyuNJ1UOHcfr"
    > />
    >
    > <table cellSpacing="0" cellPadding="0" width="785" border="0">
    > <tr>
    > <td><IMG height="132" src="Images/Top.jpg" width="785"></td>
    > </tr>
    > <tr>
    > <td>
    > <table cellSpacing="0" cellPadding="0" width="785" border="0">
    > <tr>
    > <td vAlign="top" width="160"
    > background="Images/LeftBackground2.gif">
    > <table cellSpacing="0" cellPadding="0" width="160" border="0">
    > <tr>
    > <td background="Images/LeftBackground1.gif"
    > height="431">&nbsp;</td>
    > </tr>
    > </table>
    > </td>
    > <td vAlign="top" bgColor="#e9e9e9">
    > <table cellSpacing="0" cellPadding="1" width="100%" border="0">
    > <tr>
    > <td width="5">&nbsp;</td>
    > <td><br>
    > <H2>Adressesøk</H2>
    > <P><input name="SearchText" type="text" value="Kvennberggata"
    > id="SearchText" />&nbsp;
    > <input type="image" name="SearchButton" id="SearchButton"
    > src="Images/SearchButton.gif" border="0" /></P>
    > <P>
    > <div id="Panel1">
    >
    >
    >
    > <br>
    >
    > </div>
    >
    > </P>
    > <P></P>
    > </td>
    > <td width="5">&nbsp;</td>
    > </tr>
    > </table>
    > </td>
    > <TD vAlign="top" width="1" bgColor="#212148"></TD>
    > </tr>
    > </table>
    > </td>
    > </tr>
    > <tr>
    > <td bgColor="#212148">&nbsp;</td>
    > </tr>
    > </table>
    > <SCRIPT
    >

    language="javascript">document.getElementById('SearchText').focus()</SCRIPT>
    >
    > </form>
    > </body>
    > </HTML>
    >
    >
     
    Alvin Bruney, Jan 24, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Greg H
    Replies:
    1
    Views:
    449
    David Waz...
    Jul 3, 2003
  2. Paul W
    Replies:
    4
    Views:
    4,713
    Daniel Walzenbach
    Jul 15, 2005
  3. BrianDH

    Enter Key H*ll, control enter key submit button

    BrianDH, Jan 12, 2005, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    441
    Anders Matthiessen
    Jan 12, 2005
  4. M P
    Replies:
    1
    Views:
    551
  5. Matt
    Replies:
    1
    Views:
    561
    Michael Winter
    Mar 6, 2004
Loading...

Share This Page