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 6153349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:04:47+00:00 2026-05-23T20:04:47+00:00

I am trying to create a game, where the user will see an image,

  • 0

I am trying to create a game, where the user will see an image, then go to the next page and need to click on that same image. Kind of a memory game. The problem I am having is randomly sorting the array, and being able to determine which image they clicked. On my page I have five images that are randomly populated and a submit button. I would ideally like it to check to make sure they selected one, and then compare it with what is the program selected one (in this example im not using post or anything for simplicity. I can easily code that so I just need to figure out why this doesnt work) Right now I am just randomly picking a value and then try to determine if the user clicked that same one. But I get mixed results sometimes I get the same number in my selvalue and programvalue variables. Can anyone help me? I a coding in c#

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
            {
                Random random = new Random();
                List<string> urls = new List<string> { };
                List<int> nums = new List<int> { };
                List<string> iconnames = new List<string> 
                    {
                        "images/verimage1.png", 
                        "images/verimage2.png", 
                        "images/verimage3.png", 
                        "images/verimage4.png", 
                        "images/verimage5.png" 
                    };
                int noiconlabel = random.Next(iconnames.Count);
                switch (noiconlabel)
                {
                    case 0:
                        {
                            iconnamelabel.Text = "Newspaper";
                            HiddenField2.Value = "1";
                            break;
                        }
                    case 1:
                        {
                            iconnamelabel.Text = "iPod";
                            HiddenField2.Value = "2";
                            break;
                        }
                    case 2:
                        {
                            iconnamelabel.Text = "Star";
                            HiddenField2.Value = "3";
                            break;
                        }
                    case 3:
                        {
                            iconnamelabel.Text = "Lock";
                            HiddenField2.Value = "4";
                            break;
                        }
                    case 4:
                        {
                            iconnamelabel.Text = "Die";
                            HiddenField2.Value = "5";
                            break;
                        }
                }
                for (int a = 0; a < 5; a++)
                {
                    int index = random.Next(iconnames.Count);
                    var name = iconnames[index];
                    urls.Add(name);
                    nums.Add(index + 1);
                    iconnames.RemoveAt(index);
                }

                Image1.ImageUrl = urls[0];
                Image1.CommandArgument = nums[0].ToString();
                Image2.ImageUrl = urls[1];
                Image2.CommandArgument = nums[1].ToString();
                Image3.ImageUrl = urls[2];
                Image3.CommandArgument = nums[2].ToString();
                Image4.ImageUrl = urls[3];
                Image4.CommandArgument = nums[3].ToString();
                Image5.ImageUrl = urls[4];
                Image5.CommandArgument = nums[4].ToString();

            }
    }

    protected void Image1_Click(object sender, ImageClickEventArgs e)
    {
        ImageButton img = (ImageButton)(sender);
        HiddenField1.Value = img.CommandArgument;

    }

    protected void Image2_Click(object sender, ImageClickEventArgs e)
    {
        ImageButton img = (ImageButton)(sender);
        HiddenField1.Value = img.CommandArgument ;
    }

    protected void Image3_Click(object sender, ImageClickEventArgs e)
    {
        ImageButton img = (ImageButton)(sender);
        HiddenField1.Value = img.CommandArgument;
    }

    protected void Image4_Click(object sender, ImageClickEventArgs e)
    {
        ImageButton img = (ImageButton)(sender);
        HiddenField1.Value = img.CommandArgument;
    }

    protected void Image5_Click(object sender, ImageClickEventArgs e)
    {
        ImageButton img = (ImageButton)(sender);
        HiddenField1.Value = img.CommandArgument;
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        string selvalue = HiddenField1.Value;
        string programvalue = HiddenField2.Value;

        if (selvalue == null | selvalue == "")
        {
            errorverlabel.Text = "<span style='color: red; font-size: 8pt;'>No Verification Image Selected, Please try again.</span>";
        }
        else
        {
            if (selvalue != programvalue)
            {
                errorverlabel.Text = "<span style='color: red; font-size: 8pt;'>Wrong Verification Image Selected, Please try again.</span>";
            }
        }
    }

}
  • 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-05-23T20:04:48+00:00Added an answer on May 23, 2026 at 8:04 pm

    You need to use the logic || (OR) operator, not the bit-wise | (OR) operator.

    Change:

    if (selvalue == null | selvalue == "")
    

    To

    if (selvalue == null || selvalue == "")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a PBBG (persistent browser based game) like that of
I am currently trying to create a menu system for a game and cannot
I am trying create a WCF service that leverages the WPF MediaPlayer on the
Trying to create a user account in a test. But getting a Object reference
Trying to create my first iPhone app that would play back audio. When I
Trying to create a small monitor application that displays current internet usage as percentage
I am creating a little game client that will end up connecting to a
Im trying to create a board game generator in ruby which takes images from
I am trying to have a php script that displays a url with user
I am trying to create a tic - tac - toe type of game

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.