Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 275
  • Last Modified:

use webbrowser to reach a link in a table

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!




<html>


<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>

</table>

</td>

Open in new window

0
Noero
Asked:
Noero
  • 3
  • 3
1 Solution
 
käµfm³d 👽Commented:
I think this is what you are after:

foreach (HtmlElement anchor in this.webBrowser1.Document.GetElementsByTagName("a"))
{
    if (anchor.InnerText == "APD's")
    {
        this.webBrowser1.Navigate(anchor.GetAttribute("href"));
    }
}

Open in new window

0
 
NoeroAuthor Commented:
It looks that the program doesn't come into the foreach loop. Nevertheless, Thank for your help!
0
 
käµfm³d 👽Commented:
Is that the complete HTML that you posted? Perhaps it is hosted in a page that has a frame?
0
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

 
NoeroAuthor Commented:
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?
0
 
NoeroAuthor Commented:
Well, i figured it  out ->

this.webBrowser_Main.Document.Window.Frames["NameOfFrame"].Document.GetElementsByTagName("a")

Thank you very much kaufmed!
0
 
käµfm³d 👽Commented:
NP. Sorry I didn't get back to you on your later question. Glad you figured it out though   = )
0

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now