In .NET you can use the framework helper method HttpUtility.UrlEncode to encode the string containing "&" and in the target Page use the HttpUtility.UrlDecode helper method.
In windows phone the same helper methods are available in namespace System.Net.HttpUtility.
An alternate option is to use the Silverlight Uri.EscapeUriString and Uri.EscapeDataString
Usage:
//To Escape: string encodedValue = Uri.EscapeDataString("William&Shakespeare"); NavigationService.Navigate(new Uri("/Page2.xaml?author=" + encodedValue, Urikind.Relative)); //To Unescape: string encodedValue = NavigationContext.QueryString["author"]; string author = Uri.UnescapeDataString(encodedValue);
No comments:
Post a Comment