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
Suthish NairPosted Mar 12, 2011, 1:30 PM
Suthish NairPosted Mar 12, 2011, 1:28 PM
Aman GhaiPosted Mar 12, 2011, 3:25 AM
Please help! I need to get the exact character in my code that the user keyed-in the textbox.
Raja KrishnamurthyPosted Mar 11, 2011, 9:16 AM
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
Soft CornerPosted Mar 11, 2011, 6:10 AM
private void textBox1_KeyUp(object sender, EventArgs e)
{
Yourmethod(textBox1.Text); // pass each keyed text to your method frm here
}
Aman GhaiPosted Mar 11, 2011, 5:48 AM
Soft CornerPosted Mar 11, 2011, 5:23 AM
and if not Can you please upload your code here ..
Aman GhaiPosted Mar 11, 2011, 5:11 AM
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 CornerPosted Mar 11, 2011, 5:00 AM
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