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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using enter key does not pass button value in IE6 1

Status
Not open for further replies.

Glasgow

IS-IT--Management
Jul 30, 2001
1,669
GB
Within an ASP page I have the following form:
Code:
<form name="MyLogin" method="POST" action="login.asp">
            Password 
  <input type=password name="Password">
  <input type=submit name="login" value="Login" class="ApplyButton">
</form>
Within login.asp, I have the code
Code:
Password=Trim(Request.Form("Password"))
Button=LCase(Request.Form("login"))
In IE6, when the user enters a password and clicks the login button, all behaves as I expect and the Button vraiable contains the text 'login' but if the user hits the enter key after entering the password, the value in Button is blank. I was expecting it to be "login" and it is when I use Firefox.

Any suggestions?
 
Glasgow,
I am by no means an expert, but I just built a login page myself with code that looks similar to yours. At any rate, I tried testing my page with the similar code and could not get the text to disappear off the button in IE or in Firefox.

To be honest, the last time I saw issues with text disappearing off of buttons in browsers my friend was having MAJOR issues with Active X controls, not to mention other weird issues. I don't suppose the machine you are using is having any problems?

If you are running any anti-virus software like Norton or McAfee, I would be sure that they are up to date with fixes and such... hope this helps Glasgow. By the way, are you using scripts to handle/govern the login stuff server side? I have seen some forums discuss how sometimes that can get the buttons a little wonky.
 
Thanks.

You may have misunderstood - the text is not physically disappearing from the button. It's the value returned by:
Code:
Request.Form("login")
that is unexpectedly empty.
 
Glasgow, I typed up my own example and experienced the same problem. So I went and tried to find what exactly the problem was.

Turns out this is a known IE issue, I don't have any definitive proof, but there's nothing wrong with your code, however, there is something wrong with IE.

It does not pass the value because in IE pressing the Enter key does not fire off any actions of the submit button. It's akin to passing a disabled form element.

You can kinda see that by putting a

Code:
Response.Write(Request.Form("login").count)

in your code. It prints out 0, as if that element (submit button) didn't submit with the form.

It's all Microsoft's fault!!!!! [evil]



[monkey][snake] <.
 
Thanks monksnake. Interesting.

You'd have thought they'd have sorted it out in IE7 but it has the same symptoms. Ah well.

Did you come across any useful links that document this as a known issue? If I can come up with some evidence, I can at least justify to the powers that be why I can't get this to work.
 
I didn't come across anything definitive, but I found many links where people griped about this behavior, including a MSDN IE forum. I'll take a quick look again.

[monkey][snake] <.
 
From this site:
Without the information as to what button caused the postback, the ASP.NET engine cannot raise the corresponding button's Click event. Hence, if you have a Web Form with just one single-line text input (even if there are additional input fields, like CheckBoxLists, RadioButtonLists, DropDownLists, and so on), [!]hitting enter in the text input will not cause the Button Web control's Click event to fire when using Internet Explorer - other browsers, such as FireFox, always send back the button's name/value pair, even if there is only one text input[/!].


Taken from this site:
Pressing the Enter key in a form should submit the form as if by clicking the first button, if one is present (e.g. assume HTML that has: start form, then one text field, then one button, then end form. Pressing enter in the text field will currently submit the form in IE, but it will not 'click the button' - however it will in other browsers such as Firefox);

There's 2 examples for you, like I said, nothing definitive, but I would think it enough from 2 reputable sites.


[monkey][snake] <.
 
That's great, thanks and gives me an idea - perhaps if I have another text field that's invisible, it will create a workaround. I will report back!
 
perhaps if I have another text field that's invisible, it will create a workaround
That's absolutely how you would pass the value. I'm sorry, I didn't know you were wanting a way to pass the value, just thought you wanted an explanation of why that wasn't passing the value in the submit button.

[cry]

[monkey][snake] <.
 
No problem. I wasn't specific. I just thought I was doing something dumb but apparently not. Your quotes highlighted the fact that this was only a problem when there was a single text field so pointed me down the right track.

Thanks again.
 
Adding the extra invisible text item did the trick.
 
Darn it!!! I came across that same microshaft issue posted on their web site, but didn't think it applied, as I thought it was disappearing off the button (a friend of mine had an issue with text disappearing off the buttons due to uninstalling Norton... it was weird to say the least). Well, that's it... I am just going to back to asking questions, not answering them.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top