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!

没有正确的解决方案

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top