Re: Need Enter key to trigger post

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



When I used to use FrontPage (a few weeks ago before downloading Visual Web Developer 2008 Express), all I did was insert a button on a webpage and it defaulted to be a submit button as well as automatically created a form. So from there whenever I pressed Enter on the webpage it automatically submitted.

Now with VWDExpress 2008 I tried to do the same thing; that is drag a button and then a text box onto a blank webpage.

There seems to be no automatic creation of a form and a submit button. I'll plan have a read through the articles you mentioned and see if they do allow me to emulate the FrontPage generated functionality.

Thanks.

"Steven Cheng [MSFT]" <stcheng@xxxxxxxxxxxxxxxxxxxx> wrote in message news:1Q0m9SB0IHA.1784@xxxxxxxxxxxxxxxxxxxxxxxxx
Hi Mark,

As for the first question, you can add some javascript for the
TextBox(input field)'s "onkeydown" event and post the form. Here are some
web articles mentioned this:

#Enter Key in ASP.NET - Complete Research
http://www.beansoftware.com/ASP.NET-Tutorials/Accept-Enter-Key.aspx

#Default Button Submissions in ASP.NET Pages
http://www.west-wind.com/WebLog/posts/1225.aspx

#Setting the default Button for a TextBox in ASP.NET
http://weblogs.asp.net/rajbk/archive/2003/12/11/setting-the-default-button-f
or-a-textbox-in-asp-net.aspx

For the second question, "Response.Write" will always output the parameter
from the begining of the response stream, therefore, your output will
generally display at the top of the page. Also, if you want to display some
message on page to users, I suggest you use the following means instead of
Response.Write:


You can put a Label control on the page. And then in your page's codebehind
use label.Text = "xxxx" to display the information. The advantage of this
is that the text content can be embeded correctly inside the HTML body/form
instead of at the begining of response stream.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@xxxxxxxxxxxxxx

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.




--------------------
From: "Mark B" <none@xxxxxxxx>
Subject: Need Enter key to trigger post
Date: Mon, 16 Jun 2008 12:40:09 +1200


I have a function that looks up a SQL table to see if a search term
matches.
It works fine but so far there are two things yet to work:

1) After entering a search term and pressing Enter, nothing has been
happening. It has only been searching when I click the Search button.

2) Neither of the Response.Write's have been displaying any text.

Here's the code:

<body>
<form id="form1" runat="server">
<div>

<asp:TextBox ID="SearchBox" runat="server" Width="168px"
AutoPostBack="True"
TabIndex="1"></asp:TextBox>
&nbsp;<asp:Button ID="Button1" runat="server" Text="Search" TabIndex="2" />

</div>
</form>
</body>


Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click

Response.Write("Test")
If fVerifySearch(Me.SearchBox.Text) = False Then
Response.Write("No record found.")
End If

End Sub




.


Quantcast