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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:56:29+00:00 2026-05-31T00:56:29+00:00

I just spent 2 hours trying to find out what was wrong with my

  • 0

I just spent 2 hours trying to find out what was wrong with my code. Basically, here is what I did:

        if (browser.DocumentText.Contains("Something"))
        {
            [do somwthing]
        }

I rendered the page in the WebBrowser control just before running this command, so I know for sure the text is there, but it still returns false.

I did some debugging, and I found that browser.DocumentText contains some weird form of HTML.

Now I could iterate thru the labels in the document and get the text from there, but is there a way to do it by looking at the HTML?

  • 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-31T00:56:31+00:00Added an answer on May 31, 2026 at 12:56 am

    Let me provide you a better way to do it, without using .DocumentText and having to parse all those strings, erk.

    If wbMain is your WebBrowser1 control, do the following.

    First, you need to get a ref to your element, lets say you want to access the first <A> link, on your page, you can loop through all if you want.

    This is in VB, but its the same sort of thing in C#, just different syntax.

    Dim i As Integer
    Dim aElement As HTMLAnchorElement = wbMain.Document.All.getElementByTagName("A")(0)
    
    For i = 0 To aElement.attributes.length - 1
      MsgBox aElement.attributes.item(i).name & "=" & aElement.attributes.item(i).value
    Next i
    

    This will loop through all attributes and display it in a MSGBOX in a name=value format.

    If you want to retreive it by name (attributes name) just call using aElement.getAttribute("target") to retreive the target attributes value from the a Link.

    If you want to confirm you got the right object/element, just do a aElement.outerHTML to get the full HTML code for that element only.

    Since I am using a pre.NET version, feel free to change the declaration from HTMLAnchorElement to IHTMLAnchorElement if it gives you trouble, of course, you can just use IHTMLElement if you want to go through all elements on a page, then all you’ll need to do is wbMain.Document.All(0) for first element on a page, or loop until .All.length – 1 to go through all. Remember if you are using nested For loops, don’t use i twice, use j for one of them :).

    Let me know if this answers your question or if there is more I can do to help you with your issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just spent the last 7 hours straight trying to find a way to
Okay, I just spent the last four hours trying to figure out why my
I've just spent my 2 extra hours trying to find bug in my modification
I've spent a couple hours now trying to figure this out, but I just
So I just spent the last few hours pouring over code trying to figure
newbie here, first post. I just spent like 4 hours trying to assign one
I've spent a couple hours trying to find a good answer to this.. How
Is there another way to do this? Just spent 2 hours trying to figure
I have spent hours trying to get my project working and I just can't
New to rails, and I've just spent hours trying to hunt down a bug.

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.