Submit value of a TextBox without reloading page
-
07-11-2019 - |
문제
I'm working on an ASP.NET based TicTacToe game. The problem I have with it is that: The game is played between two users. When the first one types 'x' in the TextBox I want the 'x' to be shown on the second player's computer without reloading the page. I don't know if some code will help but here is the way I did it without reloading(the user must reload the page manually... dumb):
protected void TopLeft_TextChanged(object sender, EventArgs e)
{
Application.Lock();
GameBoard gameBoard = new GameBoard();
gameBoard.board[0, 0] = char.Parse(this.TopLeft.Text);
Application["TopLeft"] = gameBoard.board[0, 0];
Application.UnLock();
}
And then, on page pre render:
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
Application.Lock();
if(Application["TopLeft"] != "0")
{
this.TopLeft.Text = Application["TopLeft"].ToString();
}
...
And so on... I'd be very thankfull to anyone who can help!
올바른 솔루션이 없습니다
제휴하지 않습니다 StackOverflow