简体   繁体   中英

Web Browser Navigation WP8

I have a problem when i try to send the URL to the browser as a tag of a Button. Look what I'm doing:

<Button Content="101" Tag="http://stackoverflow.com/questions/ask" Width="446" Click="Button_Click" />

Navigate to browser page:

private void Button_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(
                new Uri("/webbrowser.xaml?path=" +
                        HttpUtility.UrlEncode((sender as Button).Tag.ToString()),
                        UriKind.Absolute));
        }

On webbrowser.xaml I have:

 <phone:WebBrowser x:Name="MiniBrowser" HorizontalAlignment="Left" 
IsGeolocationEnabled="True"  IsScriptEnabled="True" Width="456" Margin="0,0,0,10"/>

and on webbrowser.xaml.cs :

 protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            string path = "";

            if (NavigationContext.QueryString.TryGetValue("path", out path))
            {
                if (!string.IsNullOrWhiteSpace(path))
                {
                    MiniBrowser.Navigate(new Uri(path, UriKind.Absolute));

                }
            }
        }

Can someone explain me what I'm doing wrong? Becose when I press the button i have Debuger.Break(); :-(

我认为,无需在传递时对其进行编码,如果它是强制性的,请在传递至浏览器时对其进行解码

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM