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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:31:46+00:00 2026-05-20T07:31:46+00:00

I would like to know how I can randomize the order in which some

  • 0

I would like to know how I can randomize the order in which some controls are displayed.
Basically, I have 5 hyperlinks, and I want on each load the order in which they are displayed to be randomized.
Which way I can accomplish that?
Thanks, Laziale

  • 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-20T07:31:46+00:00Added an answer on May 20, 2026 at 7:31 am

    Assuming all 5 links are in an asp panel named “pnlLinks”, and that the links are the only controls in the panel:

        <asp:Panel ID="pnlLinks" runat="server">
            <asp:HyperLink ID="HyperLink0" runat="server" Text="test1" />
            <asp:HyperLink ID="HyperLink1" runat="server" Text="test2" />
            <asp:HyperLink ID="HyperLink2" runat="server" Text="test3" />
            <asp:HyperLink ID="HyperLink3" runat="server" Text="test4" />
            <asp:HyperLink ID="HyperLink4" runat="server" Text="test5" />
        </asp:Panel>
    

    Use code like this to randomize their order:

    protected void Page_Load(object sender, EventArgs e)
    {
        var ctrls = new List<Control>();
    
        foreach (Control c in pnlLinks.Controls)
        {
            ctrls.Add(c);
        }
    
        Random rand = new Random();
        //randomize and put back in
        foreach (Control c in ctrls.OrderBy(c => rand.Next()))
        {
            pnlLinks.Controls.Remove(c);
            pnlLinks.Controls.Add(c);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i would like know some reference. I know i can googling it. but prefer
I would like to know where can I find the code which eclipse uses
I would like to know how can I display on each pages of an
would like to know how can this be implemented in Joomla. I have a
I would like to know how can I ask X11 which windows has the
I would like to know how can we tell which consumer will get the
I have basic CSS experienced so I would like to know how can I
I would like to know how can we validate the Credit Card. We have
I would like to know how Can I paas Page as Ref Parameter to
I would like to know how can i read a value of input text

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.