I am new to asp.net. Here I am trying to create a chat application. In my project there is one label and one TextBox. whenever the user enters anything in TextBox and press enter the text will be shown in Label. I tried the below code:
OnEnterKeyPress of TextBox (.aspx.cs file)
HttpRequest request = base.Request;
Ping p = new Ping();
PingReply r;
String s = request.UserHostAddress; //using own IP address for understanding purpose.
r = p.Send(s);
Response.Buffer = false;
if (r.Status == IPStatus.Success)
{
Label1.Text = TextBox1.Text;
}
I dont know how to keep the enter event. (There are no events in TextBox properties as it were in C#)
Before asking here I checked many links like Link1 Link2 Link3 but no use. I could have used simple Javascript but the main code is in C# file.
You’ll need to put this in its own form and use javascript, since it will be in a page with other controls. You don’t want to “submit” the page every time they type something.
This will make “enter” work for the textbox. For the chat feature, to make it more interactive, you can implement with http://signalr.net/