Click here to Skip to main content
15,900,589 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi, I am trying to use the Silverlight Navigation Service to send 2 values from different text boxes and then extract the values on a different page called page.xaml. However it never seems to work could someone please help.

MainPage.xaml code

C#
private void button1_Click(object sender, RoutedEventArgs e)
       {
           NavigationService.Navigate(new Uri("/page.xaml?msg=" + textBox1.Text + "msg2=" + textBox2.Text, UriKind.Relative));
       }



page.xaml code

C#
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
     {

         base.OnNavigatedTo(e);

         string msg = "";

         string msg2 = "";

         if (NavigationContext.QueryString.TryGetValue("msg", out msg))
             p1.Text = msg;


        if (NavigationContext.QueryString.TryGetValue("msg2", out msg2))
           p2.Text = msg2;


     }
Posted
Comments
[no name] 19-Mar-11 11:52am    
Ad what is happening? Does the navigation fail? Are the query string values not present? We need a little more information.
netzure 19-Mar-11 14:40pm    
The first query string will be the contents of the first textbox + msg2= and then thw contwnts of the 2nd text box.
The second text block shows the content of the first text box

1 solution

you need to separate your query strings by "&"

for example "?q1=v1&q2=v2&q3=v3"
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900