Click to See Complete Forum and Search --> : Problem with command button's access key and Textbox Value


yesrajesh
February 2nd, 2005, 06:47 AM
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

cmiskow
February 3rd, 2005, 01:28 PM
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.

yesrajesh
February 4th, 2005, 12:45 AM
Hi cmiskow,

Thanks for your reply.

Can you explain me in brief?

cmiskow
February 4th, 2005, 09:25 AM
Take whatever javascript you have for the onblur event and wrap it in a javascript function, like this:


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.

yesrajesh
February 7th, 2005, 12:00 AM
Thanks a lot cmiskow,

It works well for me...

Bye

Regards
S.Raja Sekaran