在MainPage.xam 中有一个PasswordBox
,如果输入正确的密码,就可以访问Address.xaml。
密码(一个名为 的字符串masterpass
)设置为“0000”,并且可以选择更改它,但每次打开应用程序时,密码都会再次设置为“0000”
我做错了什么?
这是代码:
public partial class MainPage : PhoneApplicationPage
{
// Constructor
private string masterpass ="0000";
public MainPage()
{
InitializeComponent();
}
private void CustomersButton_Click(object sender, RoutedEventArgs e)
{
if (String.Compare(inizio.Password, masterpass)==0)
{
NavigationService.Navigate(new Uri("/Address.xaml", UriKind.Relative));
}
else
{
MessageBox.Show("Wrong password, please try again", "Error", MessageBoxButton.OK);
}
}
private void Save_Click(object sender, RoutedEventArgs e)
{
if (String.Compare(vecchio.Password, masterpass) == 0)
{
if (String.Compare(newmaster.Password, repeatmaster.Password) == 0)
{
masterpass = newmaster.Password;
MessageBox.Show("Password changed", "Confirmation", MessageBoxButton.OK);
}
else
{
MessageBox.Show("New password doesn't match confirmation", "Error", MessageBoxButton.OK);
}
}
else
{
MessageBox.Show("Wrong master password, please try again", "Error", MessageBoxButton.OK);
}
}
}
感谢大家