Reputation: 3
I'm using WBC in my project but I don't need it to be added to the form, I tried to call Navigate method but still get empty string when retrieving
the WBC .DocumentTitle!
Upvotes: 0
Views: 169
Reputation: 2321
As noted the title can only be retrieved after it has been set. To know when that happens, in addition to DocumentCompleted event there is also a WebBrowser.DocumentTitleChanged event that is convenient and could simplify your logic.
Also, presumably, the latter event would also fire when title changes after the document is loaded via Javascript.
Upvotes: 1
Reputation: 7614
Navigate is asynchronous, that means it goes to that web page on another thread and does not wait until it finishes. You are trying to get the Title immediatelly, but it is not set yet.
You should attach to DocumentCompleted
event on the WBC and check for title there.
Upvotes: 2