Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7803713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:40:25+00:00 2026-06-02T01:40:25+00:00

Hello, how do you assign names through a browser. Picture this, your trying to

  • 0

Hello, how do you assign names through a browser.

Picture this, your trying to sign up a name on a browser text box in order to join the game with your name saved in your browser as a cookie. There is possible of multiple players that can sign their names, but the game is only two players. How can I set player name that goes to my website, types in his name in a text box that gets saved into a cookies, and then he presses a join button to beings to send requests to the host to look for another player for a game.

My question would be since the player is two player, tic tac toe actually, after I have set their chosen names to a variable string, how can I assign their name to the physical player 1 and player 2 in the game, since one player goes first and one player goes second.

I though of who ever began sending requests to find another player becomes the first player (X), so who ever answers that request, responds to be the second player, the O player. Is that possible to do?

I’m running Visual Studios ’08, using ASP.NET website forms. So generally using text boxes, buttons, MapPathing Stream Reader for data, and cookies.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T01:40:27+00:00Added an answer on June 2, 2026 at 1:40 am

    This is a lot to look over, but should give you a very good starting point:

    ASPX:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MultipleUsers.aspx.cs" Inherits="WebApplicationCS2.MultipleUsers" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:ScriptManager runat="server" ID="ScriptManager1"></asp:ScriptManager>
            <div style="float:left; border:1px solid gray; min-height:200px; width:40%;">
                <asp:Timer runat="server" ID="tmrUsersList" Interval="1000"></asp:Timer>
                <asp:UpdatePanel runat="server" ID="pnlAjaxUserList">
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="tmrUsersList" />
                    </Triggers>
                    <ContentTemplate>
                        <table style="width:100%;">
                            <asp:Repeater runat="server" ID="rptUsersList">
                                <ItemTemplate>
                                    <tr>
                                        <td>
                                            <asp:Label runat="server" ID="lblUserName" Text='<%# Eval("UserName")%>' />
                                        </td>
                                        <td>
                                            <asp:LinkButton runat="server" ID="lnkChallenge" Enabled='<%# Eval("CanChallenge")%>' 
                                                Text="Challenge" CommandArgument='<%# Eval("UserName")%>'
                                                OnCommand="lnkChallenge_Command" />
                                        </td>
                                    </tr>
                                </ItemTemplate>
                            </asp:Repeater>
                        </table>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </div>
            <div style="float:left;">
                Choose username:
                <asp:TextBox runat="server" ID="txtChosenName"></asp:TextBox>
                <asp:Button runat="server" ID="btnSignin" Text="Sign In" 
                    OnClick="btnSignin_Click" />
                <br />
                <asp:Label runat="server" ID="lblMessage" ForeColor="Red" Visible="false" EnableViewState="false"></asp:Label>
            </div>
        </div>
        </form>
    </body>
    </html>
    

    Code-behind:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    namespace WebApplicationCS2
    {
        public partial class MultipleUsers : System.Web.UI.Page
        {
            private const string UserNameKey = "SitePlayer_UserName";
            private string CurrentUserName;
            private List<GameUser> lGameUsers;
    
            protected void Page_Load(object sender, EventArgs e)
            {
                HttpCookie playerCookie = Request.Cookies[UserNameKey];
                CurrentUserName = (playerCookie != null ? playerCookie.Value : null);
                if (CurrentUserName != null)
                {
                    // Update cache to indicate user is still online.
                    Cache.Add(UserNameKey + CurrentUserName, CurrentUserName, null,
                              System.Web.Caching.Cache.NoAbsoluteExpiration,
                              TimeSpan.FromMinutes(1), System.Web.Caching.CacheItemPriority.Normal, null);
                }
    
                lGameUsers = GetUserList();
                rptUsersList.DataSource = lGameUsers;
                rptUsersList.DataBind();
            }
    
            protected void btnSignin_Click(object sender, EventArgs e)
            {
                string chosenName = txtChosenName.Text.Trim();
                foreach (GameUser u in lGameUsers)
                {
                    if (string.Compare(chosenName, u.UserName, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        lblMessage.Text = "Username already in use.";
                        lblMessage.Visible = true;
                        return;
                    }
                }
                Cache.Add(UserNameKey + chosenName, chosenName, null,
                          System.Web.Caching.Cache.NoAbsoluteExpiration, 
                          TimeSpan.FromMinutes(1), System.Web.Caching.CacheItemPriority.Normal, null);
                Response.AppendCookie(new HttpCookie(UserNameKey, chosenName));
            }
    
            protected void lnkChallenge_Command(object sender, CommandEventArgs e)
            {
    
            }
    
            class GameUser
            {
                public string UserName { get; set; }
                public bool CanChallenge { get; set; }
            }
            private List<GameUser> GetUserList()
            {
                List<GameUser> userList = new List<GameUser>();
                foreach (System.Collections.DictionaryEntry cacheItem in Cache)
                {
                    if (cacheItem.Key.ToString().StartsWith(UserNameKey))
                    {
                        string name = cacheItem.Value.ToString();
                        if (string.Compare(CurrentUserName, name, StringComparison.OrdinalIgnoreCase) != 0)
                        {
                            GameUser u = new GameUser() 
                            {
                                UserName = name,
                                CanChallenge = (CurrentUserName != null)
                            };
                            userList.Add(u);
                        }
                    }
                }
                return userList;
            }
        }
    }
    

    To see the code in action, run the website, browse to the form, and sign in, using two different browsers.

    Steps that remain for you to do are things like validating a user only signs in once, wiring up the Challenge link button, etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am having and by using jquery ineed to assign another text hello to
Hello everyone I am trying to resize an image of 700kb with imagecreatefromjpeg. This
Is it possible to assign Image to label text from Javascript I tried this
I'm attempting to draw a text box on the screen. If I assign width
hello i have to assign a matrix to a double pointer i wrote this
Hello (Sorry for my bad English) Is it bad practice to assign object to
Hello I am trying to save a bitmap image in a basic image editor
Hello! I'm not even sure if this is possible, but hopefully it is in
Assign object literal properties var foo = { bar : 'hello'}; Ternary var cats
Hello to all that read I am self learning C++ from a text book.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.