Enter behaviour on textbox

Discussion in 'ASP .Net' started by Eric, Jun 8, 2010.

  1. Eric

    Eric Guest

    Hi,

    I have a multiview view with a panel on it and in that panel a table with
    several controls (2 dropdown,3 textbox, 2 button, 1 gridview).

    When data is entered in one textbox and button1 is pressed, it puts the data
    in a gridview.
    Since the data in the textbox is a number I want it to respond to the Enter
    key.
    Hitting the enter key should do the same as the button.

    I have tried it by putting the panels defaultbutton on that button but while
    the page does a refresh, it does not go to the button click event.

    I have given the textbox an argument for the onkeydown event, but it also
    doesn't do it. (
    txtVerplaatsenArtikelNummer.Attributes.Add("onkeydown", "if(event.which ||
    event.keyCode){if ((event.which == 13) || (event.keyCode == 13))
    {document.getElementById('" + btVerplaatsenNaarLijst.UniqueID +
    "').click();return false;}} else {return true}; ")
    )


    How can I solve this?
    I cannot use the textchanged event because I need to clear the textbox after
    the data has been put in the table.

    please help me.

    rg,
    Eric
     
    Eric, Jun 8, 2010
    #1
    1. Advertising

  2. Eric

    Eric Guest

    "Eric" wrote:

    > Hi,
    >
    > I have a multiview view with a panel on it and in that panel a table with
    > several controls (2 dropdown,3 textbox, 2 button, 1 gridview).
    >
    > When data is entered in one textbox and button1 is pressed, it puts the data
    > in a gridview.
    > Since the data in the textbox is a number I want it to respond to the Enter
    > key.
    > Hitting the enter key should do the same as the button.
    >
    > I have tried it by putting the panels defaultbutton on that button but while
    > the page does a refresh, it does not go to the button click event.
    >
    > I have given the textbox an argument for the onkeydown event, but it also
    > doesn't do it. (
    > txtVerplaatsenArtikelNummer.Attributes.Add("onkeydown", "if(event.which ||
    > event.keyCode){if ((event.which == 13) || (event.keyCode == 13))
    > {document.getElementById('" + btVerplaatsenNaarLijst.UniqueID +
    > "').click();return false;}} else {return true}; ")
    > )
    >
    >
    > How can I solve this?
    > I cannot use the textchanged event because I need to clear the textbox after
    > the data has been put in the table.
    >
    > please help me.
    >
    > rg,
    > Eric
    >



    I just found out that when I put the defaultbutton of the panel on the
    button I want to be clicked, it does not work if the cursor is in the
    textbox, but if I click somewhere in the panel then it does work.

    Why is it not working on the textbox?

    rg,
    Eric
     
    Eric, Jun 8, 2010
    #2
    1. Advertising

  3. Eric

    James Irvine Guest

    "Eric" <> wrote in message
    news:...
    > "Eric" wrote:
    >
    >> Hi,
    >>
    >> I have a multiview view with a panel on it and in that panel a table with
    >> several controls (2 dropdown,3 textbox, 2 button, 1 gridview).
    >>
    >> When data is entered in one textbox and button1 is pressed, it puts the
    >> data
    >> in a gridview.
    >> Since the data in the textbox is a number I want it to respond to the
    >> Enter
    >> key.
    >> Hitting the enter key should do the same as the button.
    >>
    >> I have tried it by putting the panels defaultbutton on that button but
    >> while
    >> the page does a refresh, it does not go to the button click event.
    >>
    >> I have given the textbox an argument for the onkeydown event, but it also
    >> doesn't do it. (
    >> txtVerplaatsenArtikelNummer.Attributes.Add("onkeydown", "if(event.which
    >> ||
    >> event.keyCode){if ((event.which == 13) || (event.keyCode == 13))
    >> {document.getElementById('" + btVerplaatsenNaarLijst.UniqueID +
    >> "').click();return false;}} else {return true}; ")
    >> )
    >>
    >>
    >> How can I solve this?
    >> I cannot use the textchanged event because I need to clear the textbox
    >> after
    >> the data has been put in the table.
    >>
    >> please help me.
    >>
    >> rg,
    >> Eric
    >>

    >
    >
    > I just found out that when I put the defaultbutton of the panel on the
    > button I want to be clicked, it does not work if the cursor is in the
    > textbox, but if I click somewhere in the panel then it does work.
    >
    > Why is it not working on the textbox?
    >
    > rg,
    > Eric
    >



    Maybe this will work for you:

    <asp:panel ID="Panel1" defaultbutton="ButtonSearchx" runat="server">

    <span style="float:left; clear:both; padding-left:3em;" >

    <asp:TextBox ID="TextBoxSearchString" Width="32em" runat="server"
    TabIndex="0"></asp:TextBox>

    <asp:Button ID="ButtonSearchx" runat="server" Font-Size=".7em" TabIndex="1"
    Font-Names="Comic Sans MS;Purisa" OnClick="ButtonSearchx_Click"
    Text="Search" />

    <asp:CheckBox ID="CheckBox1" Font-Size="small" Text="exact match"
    runat="server" />

    </span>

    </asp:panel>



    Here's where it's used:

    http://foodinfo.us/Default.aspx
     
    James Irvine, Jun 10, 2010
    #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. Imran Aziz
    Replies:
    2
    Views:
    11,476
    Imran Aziz
    Sep 5, 2005
  2. =?Utf-8?B?am9l?=
    Replies:
    0
    Views:
    738
    =?Utf-8?B?am9l?=
    Sep 28, 2006
  3. Sunfire
    Replies:
    2
    Views:
    1,066
    Sunfire
    Nov 6, 2007
  4. BrianDH

    Enter Key H*ll, control enter key submit button

    BrianDH, Jan 12, 2005, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    409
    Anders Matthiessen
    Jan 12, 2005
  5. HopfZ
    Replies:
    0
    Views:
    581
    HopfZ
    Aug 28, 2006
Loading...

Share This Page