IsolatedStorage实现软件登陆时的密码验证
2011-12-29 21:57
363 查看
Login.xaml:
MainPage.xaml:
public partial class Login : PhoneApplicationPage { private const string pwd = "pwd"; public Login() { InitializeComponent(); this.Loaded += new RoutedEventHandler(Login_Loaded); } void Login_Loaded(object sender, RoutedEventArgs e) { if (!IsolatedStorageSettings.ApplicationSettings.Contains(pwd)) { textBlock.Text = "请设定密码:"; } } private void buttonReset_Click(object sender, RoutedEventArgs e) { textBox.Text = ""; } private void buttonOK_Click(object sender, RoutedEventArgs e) { if (!IsolatedStorageSettings.ApplicationSettings.Contains(pwd)) { IsolatedStorageSettings.ApplicationSettings[pwd] = textBox.Text; IsolatedStorageSettings.ApplicationSettings.Save(); NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative)); } else { if (textBox.Text.Equals(IsolatedStorageSettings.ApplicationSettings[pwd] as string)) { NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative)); } else { textBlock.Text = "请重新输入:"; textBox.Text = ""; } } } }
MainPage.xaml:
public partial class MainPage : PhoneApplicationPage { private const string pwd = "pwd"; // 构造函数 public MainPage() { InitializeComponent(); this.Loaded += new RoutedEventHandler(MainPage_Loaded); this.BackKeyPress += new EventHandler<System.ComponentModel.CancelEventArgs>(MainPage_BackKeyPress); } void MainPage_BackKeyPress(object sender, System.ComponentModel.CancelEventArgs e) { MessageBoxResult msgRst = MessageBox.Show("要退出到登陆界面吗?", "提示", MessageBoxButton.OKCancel); if (msgRst == MessageBoxResult.Cancel) { e.Cancel = true; } } void MainPage_Loaded(object sender, RoutedEventArgs e) { textBlock.Text = IsolatedStorageSettings.ApplicationSettings[pwd] as string; } }
相关文章推荐
- Android实现本地密码验证登陆
- Linux下实现SSH无密码验证登陆
- 使用android-async-http-master框架实现手机登陆服务器端密码验证
- linux下实现ssh无密码验证登陆
- Eureka实现Security Basic 验证(web登陆验证:输入用户名密码)
- Linux下实现SSH无密码验证登陆
- Struts实现注册(登陆)的验证过程
- DoNet用Ajax实现对修改密码时输入数据合法性的验证
- Java连接MySQL数据库实现用户名密码的验证方法 Java语句中sql查询语句'' ""作用
- 使用拦截器实现通用的登陆验证和日志记录
- Laravel框架用户登陆身份验证实现方法详解
- jQuery+ajax实现修改密码验证
- ssh实现无密码登陆
- 如何实现验证两次输入的密码是否一致
- spring boot整合CAS Client实现单点登陆验证的示例
- java web笔记——软件三层结构&MVC模式实现注册登陆案例
- sql server 2008 r2 修改sa密码 通过sql server 身份验证登陆
- nginx+lua实现登陆验证
- 利用ASIHTTPRequest 实现一个简单的登陆验证