I have a multiline textbox & I have associated a Javascript function call 'NavigateID()' with onKeyup event of this textbox. In this function, I need to know the character that the user just typed in the textbox.
How can i get the character that the user just typed in textbox?
Please help urgently!
Loading

Soft CornerRank #1,221 · 1.5K reputationPosted Mar 11, 2011, 12:00 AM EST
Instead of using keyup event , try with textBox_Leave event that is just bcz of keyup will fire everytime
and u will not get the whole text of textbox which user has entered.
and then pass textbox.Text to your javascript from this textBox_Leave event
Aman Ghai21 reputationPosted Mar 11, 2011, 12:11 AM EST
I need to know each character as the user type in this multiline textbox & do some processing with that character. So, my KeyUp event should somehow tell me the character that the user just typed in the textbox.
Please help in this regard!
Thanks, Amandeep
Soft CornerRank #1,221 · 1.5K reputationPosted Mar 11, 2011, 12:23 AM EST
and if not Can you please upload your code here ..
Aman Ghai21 reputationPosted Mar 11, 2011, 12:48 AM EST
Soft CornerRank #1,221 · 1.5K reputationPosted Mar 11, 2011, 1:10 AM EST
private void textBox1_KeyUp(object sender, EventArgs e)
{
Yourmethod(textBox1.Text); // pass each keyed text to your method frm here
}
Raja KrishnamurthyRank #3,615 · 403 reputationPosted Mar 11, 2011, 4:16 AM EST
First you need to add attribute to that textbox to execute KeyDown function on key down like this: (page_load)
txt1.attributes.add("onKeyDown", "javascript:KeyDown(event);");
function KeyDown()
{
if(window.event) // IE
{
keynum = e.keyCode
}
else if(e.which) // Netscape/Firefox/Opera
{
keynum = e.which
}
keychar = String.fromCharCode(keynum);
NavigateId(keychar);
}
HTH.
Happy Programming!!!
Regards,
Raja
Aman Ghai21 reputationPosted Mar 11, 2011, 10:25 PM EST
Please help! I need to get the exact character in my code that the user keyed-in the textbox.
Suthish NairRank #92 · 22.8K reputationPosted Mar 12, 2011, 8:28 AM EST
Suthish NairRank #92 · 22.8K reputationPosted Mar 12, 2011, 8:30 AM EST