Click here to Skip to main content
15,897,226 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I want hyperlink to a image in WebBrowser control ,but having problem to do by following code:- webBrowser1.Document.Images[0].Document.ExecCommand("CreateLink", false, url);
Can anyone please help me.

Thanks in Advance.
Posted

hi,

u can do this using following code

For Windows Application
C#
webBrowser1.Url = new Uri("http://www.codeproject.com");

For Web Application
XML
<a href="http://www.espn.com" target="_blank">
 <img src="ahman.gif" />
</a>

Hope it helps u
Happy Coding :)
Best Luck
 
Share this answer
 
v2
Comments
AmitGajjar 24-May-12 1:10am    
Nilesh, this is not asp.net application , as user want to navigate through browser control.
Member 8898555 25-May-12 1:34am    
Hi,

Thank u, but where to write above code?
Member 8898555 25-May-12 2:13am    
if i use webBrowser1.Url = new Uri("http://www.codeproject.com");
then it will link to webBrowser not to image in webBrowser control.
Nilesh Patil Kolhapur 25-May-12 2:41am    
write this code on picturebox click event
I assume that you are using windows forms, and want to navigate to other pages on links.

if so, then this should get you started.

Navigation[^]
 
Share this answer
 
Comments
Member 8898555 25-May-12 1:37am    
yes sir, m using windows form, and i want to navigate to other pages, but want to link to image in webBrowser control, when i click on image it should open the page which i linked.
please help.
Hi,

Please check Open link in new tab webbrowser control link.

this may help you,

-Amit
 
Share this answer
 
Comments
Member 8898555 25-May-12 1:41am    
hi,

actuly m sending mail from my window form, and i used the webBrowser control to write a text or put image, I used following code to get image in WeBrowser control
:-webBrowser1.Document.ExecCommand("InsertImage", false, url);

Now i want to hyperlink that image to google page or any other page, so that when i send the image it will open that page. But having problem to do so.
Can u help me.

Thanks.
AmitGajjar 25-May-12 1:47am    
you can use http://social.msdn.microsoft.com/Forums/da-DK/winforms/thread/793dc39a-6a25-47af-b4ff-365f716ffe1b
Member 8898555 25-May-12 2:04am    
Above link used to insert an image but not to hyperlink to that image.
AmitGajjar 25-May-12 2:07am    
does the webBrowser1.Navigate works for you ?
Member 8898555 25-May-12 2:14am    
yes webBrowser1.Navigate works but it will link directly to webBrowser1 control not to image inside in WebBrowser control.

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