Enter behaviour on textbox

E

Eric

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
 
E

Eric

Eric said:
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
 
J

James Irvine

Eric said:
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
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top