Windows Develop Bookmark and Share   
 index > Windows Forms General > Opening a website in a browser, in a NEW window
 

Opening a website in a browser, in a NEW window

I have a form that has a link label that holds a website address. When the linklabel is clicked, I want to pop open a new browser window with the website. The code below causes the latest browser window (ex. hotmail) to browse to the website.

I want a new browser window to be opened.

private void llWebsite_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
{
   string sLink = e.Link.LinkData.ToString();
   if(sLink != null && sLink!=String.Empty) 
      {
         sLink = sLink.ToLower().Trim();
         System.Diagnostics.Process.Start(sLink);
      }
}

I have also tried the following:

System.Diagnostics.ProcessStartInfo x = new System.Diagnostics.ProcessStartInfo(sLink);
x.CreateNoWindow=
true; // tried both true and false
x.UseShellExecute=
true; // tried both true and false
System.Diagnostics.Process.Start(x);

Any ideas here?

Thanks

Rick Hodder  Monday, October 24, 2005 8:11 PM
Hi Rck
 
Process.Start works pretty much like cmd.exe. For that you have to use Process.Start("IExplore.exe", sLink).
 
If you want the same behavior as WinKey+R, you'll have to use Process.Start("Explorer.exe", sLink).
 
I have a form that has a link label that holds a website address. When the linklabel is clicked, I want to pop open a new browser window with the website. The code below causes the latest browser window (ex. hotmail) to browse to the website.

I want a new browser window to be opened.

private void llWebsite_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
{
   string sLink = e.Link.LinkData.ToString();
   if(sLink != null && sLink!=String.Empty) 
      {
         sLink = sLink.ToLower().Trim();
         System.Diagnostics.Process.Start(sLink);
      }
}

I have also tried the following:

System.Diagnostics.ProcessStartInfo x = new System.Diagnostics.ProcessStartInfo(sLink);
x.CreateNoWindow=
true; // tried both true and false
x.UseShellExecute=
true; // tried both true and false
System.Diagnostics.Process.Start(x);

Any ideas here?

Thanks

MigrationUser 1  Monday, October 24, 2005 1:57 PM
Hi Rck
 
Process.Start works pretty much like cmd.exe. For that you have to use Process.Start("IExplore.exe", sLink).
 
If you want the same behavior as WinKey+R, you'll have to use Process.Start("Explorer.exe", sLink).
 
I have a form that has a link label that holds a website address. When the linklabel is clicked, I want to pop open a new browser window with the website. The code below causes the latest browser window (ex. hotmail) to browse to the website.

I want a new browser window to be opened.

private void llWebsite_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
{
   string sLink = e.Link.LinkData.ToString();
   if(sLink != null && sLink!=String.Empty) 
      {
         sLink = sLink.ToLower().Trim();
         System.Diagnostics.Process.Start(sLink);
      }
}

I have also tried the following:

System.Diagnostics.ProcessStartInfo x = new System.Diagnostics.ProcessStartInfo(sLink);
x.CreateNoWindow=
true; // tried both true and false
x.UseShellExecute=
true; // tried both true and false
System.Diagnostics.Process.Start(x);

Any ideas here?

Thanks

MigrationUser 1  Monday, October 24, 2005 1:57 PM
I think that the "open in new window" is driven by user preferences, not software.

In firefox, I know, there is an option for "Reuse open windows for new links", which I always deselect.
Ben Scheirman  Monday, October 24, 2005 8:32 PM
>>iexplore

Thanks!
Rick Hodder  Monday, October 24, 2005 9:39 PM

You can use google to search for other answers

Custom Search

More Threads

• Form example
• Need to implement Multi Level Undo functionality framework based on OO Design.
• Make Form modal to external hWnd
• What tools exist for reading binary files
• Lock Column width in a listView
• Has KeyDown changed in .NET 3.5?
• Sort columns in datagridview
• How to make fix digit in textbox
• MenuStrip shifts down in MDI-application ???
• Panel border color?