Wednesday, July 9, 2008

Silverlight HyperlinkButton turns page blank

Today when I was using the HyperlinkButton control on a Silverlight page and supplying it proper values for NavigateUri and Content attributes, I found that the control was not behaving properly and made the page blank while rendering in the browser.

It threw browser exception saying InvalidOperationException. This was the code which I was using

<HyperlinkButton x:Name=”lnkSports” Content="Sports Page"

NavigateUri="http://easports.com" Grid.Row="0" Grid.Column="1"/>

It happens because HyperlinkButton expects its NavigateUri property to be of type System.Uri rather than System.String


lnkSports.NavigateUri=new Uri("http://easports.com");

So a simple creation of Uri object in the code behind helped to solve this problem as shown above

No comments: