Reputation: 13
a simple IF function written for testing, the condition is clearly true, but it just skips to ELSE every time. Could somebody tell me if I'm doing something wrong?
namespace SANK
{
/// <summary>
/// Interaction logic for SignIN.xaml
/// </summary>
public partial class SignIn : Window
{
string username;
string password;
string user = "user";
string pass = "pass";
public SignIn()
{
InitializeComponent();
}
private void LogInButton_Click(object sender, RoutedEventArgs e)
{
password = PassBox.ToString();
username = UserBox.ToString();
bool jednako = String.Equals(password, pass, StringComparison.OrdinalIgnoreCase);
bool jednako2 = String.Equals(username, user, StringComparison.OrdinalIgnoreCase);
if (jednako&&jednako2)
{
SignedIn.Visibility=Visibility.Visible;
Application.Current.MainWindow.Show();
this.Hide();
}
else
{
Wrong.Visibility = Visibility.Visible;
}
}
}
Upvotes: 0
Views: 76
Reputation: 149
You can still use PaswordBox, but to get text from Passwordbox you have to use this:
password = PassBox.Password;
Upvotes: 0
Reputation: 74
You should not call toString method on a class the output of password & username
password = PassBox.Text;
username = UserBox.Text;
are "System.Windows.Controls.TextBox" which doesn't make any sense!! In order to access to the value of textbox you need to call TextBox.Text property.
Happy Coding
Upvotes: 1
Reputation: 17402
Are you using TextBoxes
? If so, change it to use the .Text
property:
password = PassBox.Text;
username = UserBox.Text;
Upvotes: 5