CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2004
    Posts
    17

    Problem with command button's access key and Textbox Value

    Hi all,


    I have a page with Textbox (which is set to AutoPostback

    property to False) and a command button.

    I have a OnBlur event in javascript which will change the

    Textbox text value.

    I set AccessKey of the command Button to "B".

    The problem is when i click the Textbox and then press

    Alt+B, in my command_click event i am unable to access

    the changed value (by javascript) but the value before

    that.

    Can anyone help me in getting out of this problem?


    Advance thank you for all the replies...

    Bye

    Regards
    S.Raja Sekaran

  2. #2
    Join Date
    Aug 2004
    Posts
    191

    Re: Problem with command button's access key and Textbox Value

    You could duplicate the onblur event code in the command button's onclick event (or wrap it in a function and call it both places). I have tested this and it seems to work as you need it.
    Last edited by cmiskow; February 4th, 2005 at 10:16 AM.

  3. #3
    Join Date
    Jul 2004
    Posts
    17

    Re: Problem with command button's access key and Textbox Value

    Hi cmiskow,

    Thanks for your reply.

    Can you explain me in brief?

  4. #4
    Join Date
    Aug 2004
    Posts
    191

    Re: Problem with command button's access key and Textbox Value

    Take whatever javascript you have for the onblur event and wrap it in a javascript function, like this:

    Code:
    function ChangeText(textBoxID)
    {
        var textBox = document.getElementById(textBoxID);
        // perform text changing operations on value of textBox
    }
    and call it from the onblur event of the textbox:

    TextBox1.Attributes.Add("onblur", "ChangeText('" & TextBox1.ClientID & "');")

    Now, also add it to the onclick event of the submit button:

    Button1.Attributes.Add("onclick", "ChangeText('" & TextBox1.ClientID & "');")

    When you press alt+B, it does not blur the textbox before submitting the form. However, it does trigger the onclick event for the button, so adding the code in both places should take care of it.

  5. #5
    Join Date
    Jul 2004
    Posts
    17

    Re: Problem with command button's access key and Textbox Value

    Thanks a lot cmiskow,

    It works well for me...

    Bye

    Regards
    S.Raja Sekaran

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

Featured