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
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.
Re: Problem with command button's access key and Textbox Value
Hi cmiskow,
Thanks for your reply.
Can you explain me in brief?
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.
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