Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to submit form using Enter Key

Status
Not open for further replies.

Ovatvvon

Programmer
Feb 1, 2001
1,514
US
Using a simple form with just a text box and a button to submit it, I notice it only posts back the information if the button is clicked, but if the enter key is pressed...it posts the page (or what looks like posting the page anyway), but no data is passed.

Why is that? And how can I make it so when the user presses the enter key, it'll be just as if they clicked on the button? -Ovatvvon :-Q
 
If the textbox is a sigle line, all you need to do is turn the AutoPostBack property to true. NetAngel
 
This appears to be a shortfall for some reason. I don't understand it, but can confirm that I get the same behavior.

At the end of the day, those buttons are still just "submit" buttons, and should work exactly the same way, but for whatever reason, they don't.

You might try doing this:

<input type=submit value=Submit id=btnSubmit name=btnSubmit runat=server>

and see if that works.

hth :)
paul
penny1.gif
penny1.gif
 
Unfortunately, neither of those worked. Any other ideas by chance? -Ovatvvon :-Q
 
Ovatvvon,

Here is an excerpt from a page where it does work... I took the runat=server off, and it works fine. One thing to note, however, is that it's the only button on the page, which may be the reason that it did work. At any rate, here ya go:
Code:
<TABLE id=&quot;Table2&quot; cellSpacing=&quot;0&quot; borderColorDark=&quot;gray&quot; cellPadding=&quot;3&quot; width=&quot;300&quot; border=&quot;0&quot;>
<TR>
	<TD align=&quot;right&quot;>
	<asp:TextBox id=&quot;txtPassword&quot; runat=&quot;server&quot; TextMode=&quot;Password&quot; Width=&quot;120px&quot;></asp:TextBox>
        </TD>
</TR><TR>
	<TD align=&quot;right&quot;>
	<input type=&quot;submit&quot; id=&quot;btnLogin&quot; name=&quot;btnLogin&quot; style=&quot;width:120px&quot; value=&quot;Login&quot;>
	</TD>
</TR>
penny1.gif
penny1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top