For Mike regarding ENTER from the text box

J

JP

Hi Mike,

Thank You! I think this will get me what I am trying to
do. However, for the first attempt, it didn't work. I am
sorry, but I am still a new fish in the ocean of ASP.NET
and it would help if you could give more details on how to
use the code you gave.

This is what I did....
In the page load event I added the KeyDown event, but
changed the syntax to proper cases. Following is the exact
line I entered.
txtPassword.Attributes.Add("OnKeyDown", "return
TestForEnter()")

Now is a little confusing part for me, to add the script
in HTML codes. I added this <script></script> right after
<head></head>, not sure if that's okay!

<script>
function testForEnter() {
if (event.keyCode == 13)
{
document.all("imgLogin").click();
event.returnValue = false;
}
}
</script>

Now I run the app and for the password first character,
which is an upper case letter, I press SHIFT key and the
page's bottom left corner shows the yellow triangle
indicating an error. And the error is ...

Line: 80
Char: 1
Error: Object Expected
Code: 0
URL: http://localhost/NAVAlertData/Login.aspx

Line 80 on my HTML page is a </TR> ending tag and line 80
on my Login.aspx.vb (code behind) is commented out. So now
I don't know what to look for...

Please help....

Thanks a million again in advance!
JP
 
M

Mike Moore [MSFT]

Hi JP,

It's your capitalization. You changed attributes.add to TestForEnter.
However, you left the function as testForEnter. The initial "t" is
capitalized in one but not the other. As a side note, we usually put event
driven script inside the head section, though it will work just about
anywhere.

Thank you, Mike
Microsoft, ASP.NET Support Professional

Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computer’s security.

This posting is provided "AS IS", with no warranties, and confers no rights.


--------------------
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top