Navigate to an URL in Windows Phone using HyperlinkButton

Generally , We use the WebBrowserTask in Windows Phone to Navigate to an external URL . Alternatively , one could also use the HyperlinkButton to navigate to an external URL too.

Just set the TargetName =”_blank” and then specify the NavigateUri property of the HyperlinkButton like the below sample sourcecode

<HyperlinkButton Content="HyperlinkButton" Height="100" HorizontalAlignment="Left" Margin="26,62,0,0" Name="hyperlinkButton1" VerticalAlignment="Top" Width="396" Click="hyperlinkButton1_Click" NavigateUri="http://www.developerpublish.com" TargetName="_blank" />

If you dont set http:// before the URL , you will get the error “Cannot navigate to locations relative to a page”.

Navigate to an URL in Windows Phone using HyperlinkButton
Navigate to an URL in Windows Phone using HyperlinkButton

If you dont set the TargetName=”_blank”  , you will get the Navigation Failed error with message “System.ArgumentException: Navigation is only supported to relative URIs that are fragments, or begin with ‘/’, or which contain ‘;component/’.
Parameter name: uri”

Navigate to an URL in Windows Phone using HyperlinkButton - 2
Navigate to an URL in Windows Phone using HyperlinkButton – 2

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

In this post, you’ll learn about the Win32 Error “0x000019E5 – ERROR_COULD_NOT_RESIZE_LOG” that you get when debugging system erors in...
In this post, you’ll learn about the error “CO_E_DBERROR 0x8004E02B” that is returned when working with COM based APIs or...
In this post, you’ll learn about the Win32 Error “0x000019D0 – ERROR_LOG_BLOCK_VERSION” that you get when debugging system erors in...