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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:13:45+00:00 2026-05-27T05:13:45+00:00

HtmlAnchor[] anchorToConvert = new HtmlAnchor[]{ clickHere, leavePage}; Button[] buttonToConvert = new Button[]{ login, register};

  • 0
HtmlAnchor[] anchorToConvert = new HtmlAnchor[]{
    clickHere,
leavePage};

Button[] buttonToConvert = new Button[]{
    login,
register};

i = 0;
for (i = 0; i < anchorToConvert.Length; i++)
{
    DataRow[] result = ds.Tables[0].Select("htmlControl LIKE '" + anchorToConvert[i].ID.ToString() + "'");

    if (result.Length > 0)
    {
        anchorToConvert[i].InnerHtml = result[0]["phrase"].ToString();
    }
}
i = 0;
for (i = 0; i < buttonToConvert.Length; i++)
{
    DataRow[] result = ds.Tables[0].Select("htmlControl LIKE '" + buttonToConvert[i].ID.ToString() + "'");

    if (result.Length > 0)
    {
        buttonToConvert[i].Text = result[0]["phrase"].ToString();
    }
}

I have two arrays of html elements i need to loop through, and use the elements id attribute to select content from a database. Rather than having to create two arrays and loop through them individually, is there someway i can make a more generic array that can contain both buttons and anchors?

  • 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-27T05:13:46+00:00Added an answer on May 27, 2026 at 5:13 am

    You could use a list and check the type of the control in the list when you’re looping through:

    List<Control> ctrl = new List<Control>();
    HtmlAnchor anchor = new HtmlAnchor();
    anchor.ID = "myAnchor";
    ctrl.Add(anchor);
    
    Button btn = new Button();
    btn.ID = "MyBtn";
    
    ctrl.Add(btn);
    
    foreach (Control c in ctrl.ToList())
    {
        if (c is Button)
        {
            // Do Something
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a short snippet of C# code like this: HtmlGenericControl titleH3 = new
How do you get a server control HTMLAnchor to have href=#. It keeps resolving
I am trying to write a string link to an HtmlAnchor tag. The url
Have any one tried to activate fancybox thumbnail gallery using a button or an
import java.io.IOException; import java.net.MalformedURLException; import java.util.List; import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException; import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.html.HtmlAnchor; import com.gargoylesoftware.htmlunit.html.HtmlButton;
I have a List<> of HTMLAnchor objects (HTMLAnchor is an object from an external
So I am using HtmlUnit, and the method's signature looks like: public HtmlAnchor getAnchorByText(String
The following javascript, intended to open a new window and jump to a specified
Currently using HtmlUnit. Getting first login page is no problem, succesfully logging in, getting
How would I go about embedding an html anchor inside of an xml element?

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.