簡體   English   中英

如何在C#中使用WebBrowser控件單擊頁面1的按鈕后獲取導航的頁面2的URL

[英]How to get url of navigated page 2 after button click of page 1 using WebBrowser Control in C#

我已成功使用webbrowser控件從www.url 1 .com導航到www.url 2 .com,但我無法在asp.net Web應用程序中使用Webbrowser控件獲取導航頁面的網址,即www.url 2 .com。 。

 Example:
I navigated to www.google.com

webBrowser.Navigate("http://www.google.com");

in that page i programatically given some text and click google search button as follow

HtmlElement textElement = webBrowser.Document.All.GetElementsByName("q")[0];
textElement.SetAttribute("value", "your text to search");
HtmlElement btnElement = webBrowser.Document.All.GetElementsByName("btnG")[0];
btnElement.InvokeMember("click");

導航到[ https://www.google.co.in/?gfe_rd=cr&ei=dFMuWdWCHory8Afuwqog#q=your+text+to+search “]之后

Here my Question is How to get the that particular navigated url USING WEBBROWSER CONTROL IN c# i.e.,
**https://www.google.co.in/?gfe_rd=cr&ei=dFMuWdWCHory8Afuwqog#q=your+text+to+search"**

如果您對此問題有任何解決方案,請與我分享。

提前致謝。

由於頁面是Web應用程序,因此使用href鏈接頁面

<a href="https://www.google.com">Google </a>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM