Enter event on control

Discussion in 'ASP .Net' started by csgraham74, Jan 5, 2007.

  1. csgraham74

    csgraham74 Guest

    Hi,

    im currently building a web page that incorporates a webcontrol.

    on my webcontrol i have a textbox and a button see below

    TEXTBOX
    <asp:textbox class="mainText" id="txt_QuickSearch" Width="164px"
    runat="server"></asp:textbox>

    INPUT BOX
    <DIV align="right">&nbsp;<INPUT id="img_Search" type="image"
    height="12" width="34" src="/wb_WatsonDotNet/Images/titles/search.gif"
    name="img_Search" runat="server">

    the problem that i am having is that i want to enter details i the
    textbox and press enter then it will automatically fire the event on
    the input button.

    I have tried the 2 following methods but they do not work.

    Page.RegisterHiddenField("__EVENTTARGET", "img_Search")

    txt_QuickSearch.Attributes.Add("onkeypress", "submitForm(" &
    img_Search.ClientID & ");")

    Can anyone give me some assistance with this please.


    all help appreciated
     
    csgraham74, Jan 5, 2007
    #1
    1. Advertising

  2. csgraham74

    xamman Guest

    if i understood correctly what you are doing, i think you need to
    override createchildcontrols and use the addhandler method
     
    xamman, Jan 5, 2007
    #2
    1. Advertising

  3. csgraham74

    TiSch Guest

    Hello,

    you need a little bit javaScript:

    <HTML>
    <HEAD>
    <title>TestForm</title>
    <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
    <script language=javascript>
    function searchImage(img_Search){
    if(event.keyCode==13){
    event.returnValue=false;
    img_Search.click();
    }
    }
    </script>
    </HEAD>
    <body>
    <form id="Form1" method="post" runat="server">
    <asp:textbox id="txt_QuickSearch" runat="server"
    onkeydown="searchImage(this.nextSibling)"></asp:textbox><input
    id="img_Search" type="button" value="search">
    </form>
    </body>
    </HTML>

    Regards,
    Tim
     
    TiSch, Jan 5, 2007
    #3
    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. =?Utf-8?B?am9l?=
    Replies:
    0
    Views:
    736
    =?Utf-8?B?am9l?=
    Sep 28, 2006
  2. Sunfire
    Replies:
    2
    Views:
    1,063
    Sunfire
    Nov 6, 2007
  3. BrianDH

    Enter Key H*ll, control enter key submit button

    BrianDH, Jan 12, 2005, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    401
    Anders Matthiessen
    Jan 12, 2005
  4. Matt
    Replies:
    1
    Views:
    510
    Michael Winter
    Mar 6, 2004
  5. HopfZ
    Replies:
    0
    Views:
    576
    HopfZ
    Aug 28, 2006
Loading...

Share This Page