Forum Moderators: open

Message Too Old, No Replies

Forms

         

hal12b

6:48 pm on Apr 14, 2011 (gmt 0)

10+ Year Member



I have two form fields on a page. One is part of the master page in the top header and the other is a login in the center of the page in the page content area. After somebody fills in their username and password and if they don't click the "Sign in" button and hit the enter key on their keyboard instead, it defaults to the search field on the master page and thinks they are trying to search the site.. and no results are found.

Any idea how to rectify this?
Thanks - Hal

Demaestro

7:04 pm on Apr 14, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Are the <form> tags nested within each other?

<form id="search">

<form id="signup">

</form>
</form>

hal12b

8:26 pm on Apr 14, 2011 (gmt 0)

10+ Year Member



The form on the master page has form tags, the other one doesn't. How do I fix?

The one on master page is like this

<form id="form1" runat="server">
info info..................

</form>

Demaestro

8:38 pm on Apr 14, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



you need to add <form> tags around all the search elements including the submit button

<form id="search_form" method="post" action="/your_search_method">

search box
submit button

</form>

And make sure this form isn't nested within the "master" form

hal12b

12:10 pm on Apr 15, 2011 (gmt 0)

10+ Year Member



This is in ASP.net, not classic asp. The page posts back to itself, no "action" or need to define the "method" as far as I'm aware. Does anybody else have opinions?

mattglet

2:34 pm on Apr 15, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You need to set a DefaultButton property for your specific entry areas:

[weblogs.asp.net...]

Demaestro

2:57 pm on Apr 15, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Oh sorry for taking you the wrong ;)

Fotiman

5:43 pm on Apr 15, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



ASP.NET or ASP classic, it doesn't matter. Pressing the Enter key will trigger the first submit action within any form. The advice given was correct, you need to have your sign in fields in it's own form element, NOT within your search form.

hal12b

3:46 pm on Apr 18, 2011 (gmt 0)

10+ Year Member



Thanks for the assistance. It is working now.

hal12b

5:40 pm on Apr 18, 2011 (gmt 0)

10+ Year Member



odd.. I spoke too soon. It actually works, and in Firefox looks fine, but in IE, it pushes things around.

hal12b

2:59 pm on Jun 17, 2011 (gmt 0)

10+ Year Member



Just an update - I found that by placing this on pageload it works


Form.DefaultButton = btnSignin.UniqueID

Ocean10000

3:32 pm on Jun 17, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thanks for the update on how you manage to solve this problem.

Ocean