Click here to Skip to main content
14,641,197 members
Rate this:
Please Sign up or sign in to vote.
See more:
Dear,

My question is, I have use one link button.When i click that button,it should open a browser.I need code for this issue. Kindly send for both c#.net windows and web applications.


Thanks& Regards,

Viswanathan.M
Posted
Updated 5-Jul-11 18:52pm
v2
Rate this:
Please Sign up or sign in to vote.

Solution 1

string targetURL = @"http://pedroliska.com";
System.Diagnostics.Process.Start(targetURL);
   
v3
Comments
Viswanthan.M. 6-Jul-11 0:59am
   
i need this in C# .net coding
Viswanthan.M. 6-Jul-11 1:20am
   
Its working... thank you
[no name] 6-Jul-11 1:39am
   
welcome
   
This is correct answer, my 5. OP can formally accept it (I recommend it.)
However, please see my alternative solution -- in many cases it would be better.
--SA
[no name] 6-Jul-11 1:43am
   
your solution is great. This will help us open the page on our window (including navigation). :)
Christian Graus 6-Jul-11 2:51am
   
Of course, it was also my solution, and I am the only one who answered the other half of the question, but, whatever.
   
I see. Sure, credited :-) Thanks for the note.
--SA
Rate this:
Please Sign up or sign in to vote.

Solution 2

Use Process.Start, and point to the URL you want to open, it will open it with the default browser. That's a windows app. In a web app, you just put a hyperlink, and put target="_blank", so the link opens in a new window.
   
Comments
Viswanthan.M. 6-Jul-11 0:53am
   
Thanks for reply, but i need better
Viswanthan.M. 6-Jul-11 0:53am
   
pls
Christian Graus 6-Jul-11 2:50am
   
What do you mean 'better' ? Someone gave you the exact code, I see, but I told you exactly what you needed to do. If you could not understand me, I suggest you forget your current task and do a beginners course in C#.
   
Exactly, a 5.
--SA
Rate this:
Please Sign up or sign in to vote.

Solution 3

All those runs of some applications are not good — the use knows better what to start and how. As you need to start certain URL, it's not that bad — you already have a correct answer by 2irfanshaikh.

But the real alternative would be running a browser inside your application. Just use the class System.Windows.Forms.WebBrowser, see http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser.aspx[^].

That was for System.Windows.Forms. There is such thing for WPF as well: System.Windows.Controls.WebBrowser, see http://msdn.microsoft.com/en-us/library/system.windows.controls.webbrowser.aspx[^].

—SA
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100