从Silverlight URL中提取2个值 [英] Extracting 2 values from a Silverlight URL
本文介绍了从Silverlight URL中提取2个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用Silverlight导航服务从不同的文本框中发送2个值,然后将这些值提取到另一个名为page.xaml的页面上.但是似乎永远都无法奏效,请有人帮忙.
MainPage.xaml代码
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
private void button1_Click(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(new Uri("/page.xaml?msg=" + textBox1.Text + "msg2=" + textBox2.Text, UriKind.Relative));
}
page.xaml代码
page.xaml code
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;
}
推荐答案
,您需要使用&"
分隔查询字符串
例如?q1 = v1&q2 = v2&q3 = v3"
you need to separate your query strings by "&"
for example "?q1=v1&q2=v2&q3=v3"
这篇关于从Silverlight URL中提取2个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文