Click here to Skip to main content
11,632,715 members (82,915 online)
Rate this: bad
good
Please Sign up or sign in to vote.
This case happened when i programming.
First, i have 2 pages: MainPage.xaml and Page1.xaml.
In Mainpage.xaml, I had a button for going to Page1 and a web browser load a html file.
Code Page1.xaml
namespace test
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
            load_map();
        }
        void load_map()
        {
            // Load HTML document as a string
            Browser.IsScriptEnabled = true;
            Uri uri = new Uri("test2.html", UriKind.Relative);
            Stream stream = Application.GetResourceStream(uri).Stream;
            using (StreamReader reader = new StreamReader(stream))
            {
                // Navigate to HTML document string
                Browser.NavigateToString(reader.ReadToEnd());
            }
        }
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Page1.xaml", UriKind.Relative));
        }
 
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
 
            string msg = "";
 
            if (NavigationContext.QueryString.TryGetValue("act", out msg))
            {
                string[] result = msg.Split('|');
                string content_text = result[1];
                switch (result[0])
                {
                    case "1": load(content_text); break;
                    default: break;
                }
            }
        }
        void load(string text)
        {
 
            Browser.InvokeScript("load", text);
 
        }
    }
}

File HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
	<meta name="author" content="TM500" />
	<title>Untitled 2</title>
</head>
<script type="text/javascript">
load(var1)
{
    documents.writeln(var1);
}
</script>
<body>
hello world!!!
</body>
</html>

Code Page1.xaml

namespace test
{
    public partial class Page1 : PhoneApplicationPage
    {
        public Page1()
        {
            InitializeComponent();
        }
 
        private void button1_Click(object sender, RoutedEventArgs e)
        {
             string adr = tb1.Text;
           NavigationService.Navigate(new Uri("/MainPage.xaml?act=1|"+adr, UriKind.Relative));
        }
 
    }
}


When Mainpage.xaml get parameter from Page1.xaml then active javascript in html load(var1). I got this error:
An unknown error has occurred. Error: 80020006.
I really don't know why.
Please someone help me.
P/S: My project
Posted 13-Jun-12 23:47pm
Tokisan799
Edited 13-Jun-12 23:55pm
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 8,618
1 Sergey Alexandrovich Kryukov 8,189
2 Mika Wendelius 6,415
3 F-ES Sitecore 2,321
4 Suvendu Shekhar Giri 2,075


Advertise | Privacy | Mobile
Web03 | 2.8.150728.1 | Last Updated 14 Jun 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100