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

The question title just about says it all. I have a ASP.NET MVC 2
I'm new to ASP.NET MVC so this may be a stupid question. I have
I’ve only just started using ASP.NET MVC, and I have a somewhat trivial question:
Following on from this question: ASP.NET MVC Routing with Default Controller I have a
The context of the question is ASP.NET MVC2 / EF4. I have a number
I'm working with ASP.NET 3.5 SP1 and I have a question that I've been
I am still in the process of learning Asp.Net. I have a question .
Novice question I guess: The Scenario: I have an asp.net page that contains 6
I have a question about precompiling ASP.NET web application projects from TeamCity. This is
I am working in asp.net MVC2 application and I have question related to design

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.