Click here to Skip to main content
15,942,700 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi, so I wanna know if it possible to capture a generated link from webcontrol in C#. For example inserting a link that needs to have a search done. Pressing submit and it goes into another page. Is it possible to capture the link of that other page and use it for another purpose?

Thanks
Posted
Comments
Sergey Alexandrovich Kryukov 2-Dec-13 15:43pm    
ASP.NET, I presume? Then add the tag "ASP.NET". Or something else? The question is not clear at all. What's the problem?
—SA
slayasty 2-Dec-13 15:49pm    
the problem is im trying to find how to capture the generated website link from webcontrol when submite a form in c#.
AlexDpars 2-Dec-13 20:26pm    
Could you post some code by improving your question? May be this could help us to understand you better...

1 solution

If you are using a WebBrowser control then the links can be found in the HtmlDocument.

Here is some example code

C#
//Make sure document is loaded
private void WebBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
    HtmlElementCollection links = WebBrowser.Document.Links;
    //Do stuff...
}


You can find more information here about the WebBrowser Class here
http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser(v=vs.110).aspx[^]
 
Share this answer
 
v3
Comments
slayasty 3-Dec-13 12:21pm    
ok thanks . i will elaborate on that.
slayasty 3-Dec-13 13:47pm    
When i type WebBrowser.Document.Links i get an error saying "n object reference is required for non-static field, method or property. 'system.Windows.Forms.WebBrowser.Document.get'
austinbox 3-Dec-13 22:52pm    
You can't reference the class itself, you need to create a webBrowser control yourself, and then substitute WebBrowser to the Name of your webBrowser control.
slayasty 4-Dec-13 14:05pm    
thats what i did the first time. mm i guess i mistyped the web browser name i gave it myself. :P

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900