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

  • Home
  • SEARCH
  • 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 5966227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:46:01+00:00 2026-05-22T19:46:01+00:00

I have 6 question in 6 asp.net panel server control , I need to

  • 0

I have 6 question in 6 asp.net panel server control ,
I need to show them all panel one by one in random order( one question is visible and other invisible every time ).

I don’t know how to exclude the number from generating again .
I write like this :

    protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Random rnd = new Random();
                int startNumber = rnd.Next(1, 6);
                ShowNextPanel(startNumber);
            }
        }

    private void ShowNextPanel(int excludeNumber)
    {
        Random rnd = new Random();
        //I need to exclude the "excludeNumber" here but I don't know how !?
        int number = rnd.Next(1, 6);
        switch (number)
        {
            case 1:
                {
                    Panel1.Visible = true;
                    break;
                }
            case 2:
                {
                    Panel2.Visible = true;
                    break;
                }
            case 3:
                {
                    Panel3.Visible = true;
                    break;
                }
            case 4:
                {
                    Panel4.Visible = true;
                    break;
                }
            case 5:
                {
                    Panel5.Visible = true;
                    break;
                }
            case 6:
                {
                    Panel6.Visible = true;
                    break;
                }
        }

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
       // InsertToDB(1, DropDownList1.SelectedValue);
        Panel1.Visible = false;
        ShowNextPanel(1);

    }
    protected void Button2_Click(object sender, EventArgs e)
    {
       // InsertToDB(2, DropDownList2.SelectedValue);
        Panel2.Visible = false;
        ShowNextPanel(2);

    }
//and go on till button6_click
  • 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-22T19:46:02+00:00Added an answer on May 22, 2026 at 7:46 pm

    You can put the numbers in a list, and generate your random number not based on your real numbers, but on the remaining items in the list.

    Random random = new Random();
    List<int> nums = new {1, 2, 3, 4, 5, 6}; // or whatever you need to put there.
    List<int> result = new List<int>(); // will hold your results in order.
    while(nums.Count > 0){
        int idx = random.next(0, nums.Count);
        result.add(nums[idx]);
        nums.RemoveAt(idx);
    }
    return result;
    

    You don’t have to use int values in your nums list; it can be your Question objects, or whatever you need; What you will get is the items in a random order.

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

Sidebar

Related Questions

I have one question; In my ASP.NET MVC web application have to do certain
i build a small application with asp.net mvc framework. I have one question. I
I have a question about the login control of asp.net. I defined on my
I have what should be a fairly simple ASP.NET question, and one I thought
I have a question about how ASP.NET AJAX partial rendering actually works. Does it:
I have a question I have a project asp.net mvc which is developed in
This is a beginner level question for asp.net MVC I have the following code
I have got a question with regards to upgrading asp.net mvc applications from v1
I have a little question to community. Does ASP.NET MVC allow to execute an
simple question... Given I have an ASP.NET site, which uses a [custom] RoleProvider, Is

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.