使用独立存储的IsolatedStorageSettings对象进行页面间传值
来源:互联网 发布:新浪微博个性域名大全 编辑:程序博客网 时间:2024/06/03 16:21
在asp.net开发中页面间的传值方法有很多种,如Session、Cookie等技术,但是在Silverlight中,我们可以通过IsolatedStorageSettings这个独立存储对象来实现。
(1)、首先需要在每个需要使用传递过来的值的页面中添加命名空间:using System.IO.IsolatedStorage;
(2)、如在Login.xaml页面中,首先创建一个IsolatedStorage对象,如下:
//使用独立存储的IsolatedStorageSettings对象
private IsolatedStorageSettings appSettings = IsolatedStorageSettings.ApplicationSettings;
(3)、在登录按钮事件中,验证通过并跳转的语句后面添加如下类似于Session的用于保存用户信息,并可以在其他页面中读取该值。
...
if (!appSettings.Contains("uname"))
{
appSettings.Add("uname", this.tbUserName.Text.Trim());
}
...
(4)、在MainPage.xaml页面中,首先创建一个IsolatedStorageSettings对象,然后利用此对象来读取保存的用户信息。
...
//使用独立存储的IsolatedStorageSettings对象
private IsolatedStorageSettings appSettings = IsolatedStorageSettings.ApplicationSettings;
...
if(appSettings.Contains("uname"))
{
this.tbUserName.Text = appSettings["uname"].ToString();
}
- 使用独立存储的IsolatedStorageSettings对象进行页面间传值
- Windows Phone 独立存储之IsolatedStorageSettings
- IsolatedStorageSettings存储数据
- WP7 Isolated Storage 系列 - 3.使用IsolatedStorageSettings存储数据
- 独立存储区的使用
- Silverlight之IsolatedStorageSettings对象
- Windows Phone 7的本地存储——IsolatedStorageSettings
- Windows Phone的本地存储——IsolatedStorageSettings
- 使用SharedPreference 进行对象存储
- 使用XMLHttprequest对象进行异步调用html页面的示例
- opengl 独立着色器对象的使用
- 使用javascript进行页面间传值的问题
- jsp使用application对象进行存储
- Windows phone 7中,把页面数据存为长期存储(非IsolatedStorageFile),而是用IsolatedStorageSettings
- WP7的独立存储
- WP7的独立存储
- c# 使用独立的DLL来存储图片(资源文件)
- 使用独立的DLL来存储图片(资源文件)
- 判断描述符中是否存在英文字母
- ubuntu10编译源代码
- Trufun五周年庆典,UML产品买一送二活动
- Elsevier上发表论文的若干要求
- [新闻] 微软八月十一日发行14个安全补丁
- 使用独立存储的IsolatedStorageSettings对象进行页面间传值
- CSS网页布局强制换行和强制不换行
- Destruction Masking in Frostbite 2 using Volume Distance Fields
- 观察者模式
- LINQ to Objects(用于集合、文件、字符串对象的LINQ)
- ASP.net 4.0 新特性:Web.Config Transformation
- Android 网站资源收集大全
- 最全的Android源码目录结构详解
- 利用多线程提高程序性能(for Android)