gpt4 book ai didi

c# - 在 Windows Phone 8 页面之间将特殊字符作为字符串传递

转载 作者:太空宇宙 更新时间:2023-11-03 13:44:49 24 4
gpt4 key购买 nike

我试图将用户在文本框中输入的特殊字符作为字符串传递,例如 &#

然后将这个字符串传递给下一个页面

NavigationService.Navigate(new Uri(String.Format("/Pages/EditNote.xaml?note={0}", strText), UriKind.Relative));

EditNote.xaml 页面然后检查注释参数并获取其值

protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);

if (NavigationContext.QueryString.ContainsKey("note"))
{
noteText = NavigationContext.QueryString["note"];
}
}

问题是,当 noteText 是非字母数字字符(例如 &# 等)时,它始终为空。

我错过了什么?

最佳答案

由于特殊字符在url构造中有预定义的含义,所以会与带有特殊字符的url + data混淆。

如果在您的上下文中没问题,您也可以使用 IsolatedStorageSettings。

源页面:

IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;

if (!settings.Contains("note"))
{
settings.Add("note", "$#$#$#%#%#????===&&&&&some note Text!#@#@@@ someText @$$@%@%@%@^@@&^*@&(*(**)*)_((_(_(_*(&*(^*&%&%*)");
}

settings.Save();

NavigationService.Navigate(new Uri(@"/Pages/EditNote.xaml", UriKind.Relative));

目标页面:

string note = string.Empty;
IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
if (settings.Contains("note"))
{
note = settings["note"] as string;
}

在这里你可以传递所有特殊字符。

关于c# - 在 Windows Phone 8 页面之间将特殊字符作为字符串传递,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15738345/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com