When enter key pressed then event has to be fired
i have chat application...when click on send button as well as Enter key then message is going to send...for send button event generated ....but what about enter key ..please help me
Know the answer? Post it. Somebody with the same question will find it here.
Sunny SharmaRank #223 · 11.1K reputationPosted Jun 20, 2013, 8:28 AM EDT
Use the pattern below:
--------------------------------------------
private void ChatWindow_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
btnSendMessage.PerformClick();
}
}
--------------------------------------------
Mark as answer if it helps.
Cheers!
yadagiri uppariRank #7,043 · 250 reputationPosted Jun 20, 2013, 8:44 PM EDT
as performClick() not found........pls help me
Pankaj PandeyRank #642 · 3.7K reputationPosted Jun 20, 2013, 9:37 PM EDT
if (e.KeyCode == Keys.Enter)
{
//just copy and paste the code that you written on send button event.
}
yadagiri uppariRank #7,043 · 250 reputationPosted Jun 20, 2013, 9:49 PM EDT
after typing some text in richtext box then message will be sent by clicking send button or enter key.....my app is in asp.net sir what should i do please help me...send button is working properly but enter key is not working
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Jun 20, 2013, 10:14 PM EDT
now on page load write these code
protected void Page_Load(object sender, EventArgs e)
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "Shortcut", "document.attachEvent ('onkeyup',ShortcutKeys);", true);
}
and check if any problem reply i will provide sample
yadagiri uppariRank #7,043 · 250 reputationPosted Jun 20, 2013, 10:59 PM EDT
i tried with all onkeyup,onkeypress,onkeydown....but still it is not working
Sunny SharmaRank #223 · 11.1K reputationPosted Jun 20, 2013, 11:03 PM EDT
show me your aspx page code, I'll help you with that.
yadagiri uppariRank #7,043 · 250 reputationPosted Jun 20, 2013, 11:19 PM EDT
yadagiri uppariRank #7,043 · 250 reputationPosted Jun 20, 2013, 11:19 PM EDT
yadagiri uppariRank #7,043 · 250 reputationPosted Jun 20, 2013, 11:22 PM EDT
yadagiri uppariRank #7,043 · 250 reputationPosted Jun 21, 2013, 12:09 AM EDT
I need your help sir
Sunny SharmaRank #223 · 11.1K reputationPosted Jun 21, 2013, 1:34 AM EDT
sorry to ask you but It's really a bit annoying navigating through all these code with so many commented lines. Suggest you to share your project in whole or slice the relevant part only.
yadagiri uppariRank #7,043 · 250 reputationPosted Jun 21, 2013, 2:06 AM EDT
aspx:
yadagiri uppariRank #7,043 · 250 reputationPosted Jun 21, 2013, 2:08 AM EDT
yadagiri uppariRank #7,043 · 250 reputationPosted Jun 21, 2013, 2:48 AM EDT
Sunny SharmaRank #223 · 11.1K reputationPosted Jun 21, 2013, 6:06 PM EDT
Sorry to respond you a little late. The problem that I can see in your page is that you're not grabbing the Text Editor properly. Do like this inside your script block:
--------------------------------------------------------------
---------------------------------------------------------------------
Hope this helps!
Cheers!
Iftikar HussainRank #423 · 5.9K reputationPosted Jun 25, 2013, 4:01 AM EDT
Please use like below in your aspx page
Let me know if you need more details
Regards,
Iftikar
Remember to click "Mark as Answer" on the post, if it helps you.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts