use webbrowser to reach a link in a table

Posted on 2011-10-25
Last Modified: 2012-05-12
Hello guys,

I am currently on a Csharp project wich retrieves datas from website. in order to navigate I am used to use webBrowser.Document.GetElementByID(Idresearched) method. But in a certain html page I am pretty lost;

with html pages with button I can reach them with GetElementByID or Invoke them with GetElementByType method, but in this case there is no button just a table of link. The table does not have id.

I want to reach APD's with href="apdreportsmenu.cfm?Skip='Y'&oops=#oops#" which opens the page I am interested into.

I should be so happy to get some clue for accessing it!

Thanks in advance!


<LINK rel="stylesheet" type="text/css" href="uhonon.css">

<body style="margin-left:12%;">

<table border="0" width=90% cellpadding="10" height="90%" align="center" >

<tr><td colspan="1" width="33%" align="left"  bgcolor="white" >

<table border="0" width=100% cellpadding="1" height="100%" align="right" >

<tr><td align="left" nowrap height="10"><a href="AdminChoice2Menu.cfm?Skip='Y'&oops=#oops#" target="_top" ><b>Appls</b></a></td></tr>

<tr><td align="left" nowrap height="10"><a href="A2Menu.cfm" ><b>AOR</a></td></tr>

<tr><td align="left" nowrap height="10"><a href="BLMTREE2.cfm?Skip='Y'&oops=#oops#&RequestTimeout=3500" target="_top" ><b>Ag</a></td></tr>

<tr><td align="left" nowrap height="10"><a href="apdreportsmenu.cfm?Skip='Y'&oops=#oops#" target="_top" ><b>APD's</a></td></tr>

<tr><td align="left" nowrap height="10"><a href="BasinsMenu.cfm?Skip='Y'&oops=#oops#"  target="_top" > <b>Basb</a></td></tr>

<tr><td align="left" nowrap height="10"><a href="cbMenu.cfm?Skip='Y'&oops=#oops#" target="_top" ><b>CB</a></td></tr>

<tr><td align="left" nowrap height="10"><a href="ScompcompMenu.cfm?Skip='Y'&oops=#oops#" target="_top" ><b>Comp</a></td></tr>

<tr><td align="left" nowrap height="10"><a href="coMenu.cfm?Skip='Y'&oops=#oops#"  target="_top"  ><b>Cor </a></td></tr>

<tr><td align="left" nowrap height="10"><a href="couMenu.cfm?Oops=#oops#&Skip='Y'&oops=#oops#"  target="_top"   ><b>Cou</a></td></tr>

<tr><td align="left" nowrap height="10"><a href="urecordsMenu.cfm?Skip='Y'&oops=#oops#"  target="_top"  ><b>Down Load</a></td></tr>

<tr><td align="left" nowrap height="10"><a href="Electronicfilingmenu.cfm" target="_top" ><b>Electronic Filing</a></td></tr>

<tr><td align="left" nowrap height="10"><a href="craig/craigie.html?Skip='Y'&oops=#oops#"  target="_top"  ><b>Envir</a></td></tr>

<tr><td align="left" nowrap height="10"><a href="FMenuNew.cfm"><b>Field</b></a></td>



Open in new window

Question by:Noero
    LVL 74

    Accepted Solution

    I think this is what you are after:

    foreach (HtmlElement anchor in this.webBrowser1.Document.GetElementsByTagName("a"))
        if (anchor.InnerText == "APD's")

    Open in new window


    Author Comment

    It looks that the program doesn't come into the foreach loop. Nevertheless, Thank for your help!
    LVL 74

    Expert Comment

    by:käµfm³d 👽
    Is that the complete HTML that you posted? Perhaps it is hosted in a page that has a frame?

    Author Comment

    Indeed, the table is in a frame named Menu Frame, could you say me what function I should use to specify webbrowser to access to table?

    Author Closing Comment

    Well, i figured it  out ->


    Thank you very much kaufmed!
    LVL 74

    Expert Comment

    by:käµfm³d 👽
    NP. Sorry I didn't get back to you on your later question. Glad you figured it out though   = )

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Suggested Solutions

    For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK ( for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
    More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now