Results 1 to 9 of 9

Thread: KeyPress event in a text box

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Indiana
    Posts
    612

    KeyPress event in a text box

    In VB 6.0 I could use the following to move the cursor to the next text box if the user hit the Enter key.
    VB Code:
    1. Private Sub Text1_KeyPress(KeyAscii As Integer)
    2.    If KeyAscii = 13 Then
    3.      Keyascii = 0
    4.      Text2.SetFocus
    5.    End If
    6. End Sub

    Is there a VB way to use this in .Net for a web page or do you have to use Java or HTML?

    Some examples would be greatly apreciated.

    Thanks!
    David Wilhelm

  2. #2
    Junior Member
    Join Date
    Oct 2003
    Posts
    17
    You are going to have a few problems with trying to move the cursor with the enter key.

    First the enter Key on a Web Page is by default the Submit action

    second if you are trying to use VB to capture keypress events you are reposting the data back to the server on every keypress. You should use Java and make it a client side event.

    Hope that helps

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Indiana
    Posts
    612
    Well, since I don't know much about Java, that doesn't help at all. I was hoping to see some examples of some code that would do what I need it to do....
    David Wilhelm

  4. #4
    Junior Member
    Join Date
    Oct 2003
    Posts
    17
    Again, I dont think you want to change the enter key. it is the Default Key for submitting a page.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Indiana
    Posts
    612
    I'm sure you have a valid point. But when the Executive Vice president of the company I work for wants something, I have to do my best to deliver what he wants.

    Does anyone know how to get the key pressed on a web page?
    David Wilhelm

  6. #6
    Frenzied Member
    Join Date
    May 2002
    Posts
    1,602
    I know the feeling... I am developing web apps and dll components for a bunch of people that are requesting the craziest stuff... sometimes you have to make them understand that it is IMPOSSIBLE... or convice them that you need additional resources to make it happen (that buy you enough time to learn javascript... hehe)...

    This task might not be that difficult... but I have some crazy examples of suggestions...


    happy coding
    Henrik

  7. #7
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    It is your job to show him EVERY web site on the internet until he gets the point in his head. If he still believes that he should get what he wants, then tell him it is going to cost him some HEAVY R&D money to figure out the best way to do such a thing.

    I can't stand it when people don't stand up for this stuff. These are conventions for a reason. This is something that is built into IE, it isn't something you just change for the hell of it.

    Tell him/her that it can't be done without a serious investment of time. Put it in dollar values how much it is going to cost them (like your hours times the amount you make plus how much you make for the company if your time was used elsewhere). This is something that will stop an unreasonable request from happening fast! I do it all the time. I tell people to get used to things that are convention based. If they want other than conventions, I show them how much extra it will cost. They stop there....

    Another thing, you can probably do this with javascript, you probably don't need Java, but I don't have any examples for you.

  8. #8
    Frenzied Member
    Join Date
    May 2002
    Posts
    1,602
    here here

  9. #9
    Junior Member
    Join Date
    Oct 2003
    Posts
    17
    I agree, I am really tired of being asked for web apps that have Fat client functionality If you want a fat client get a fat client.


    tal mcmahon

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width