29
Sep

Open/Navigate to an external link

Post a comment » Popularity: 10%

The code helps to you navigate to an external link or website using code and HyperlinkButton. Please not that if you are running the application in out of browser mode, the C# will not work . In such case, you have to use HyperlinkButton to open an external link.

Open external link

Open link in c#:
using System.Windows.Browser;
private void Button_Click(object sender, RoutedEventArgs e)
{
    Uri uri = new Uri("http://silverlike.net", UriKind.Absolute);
    HtmlPage.PopupWindow(uri, "_blank", new HtmlPopupWindowOptions() { Width = 800, Height = 600};
    // or
    HtmlPage.Window.Navigate(uri, "_blank");
}
Open link using HyperlinkButton:
<HyperlinkButton  Content="Silverlike" NavigateUri="http://silverlike.net" TargetName="_blank"/>
  • DZone
  • Digg
  • del.icio.us
  • StumbleUpon
  • Reddit

Related Posts

Leave a Reply