Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Access the masterdetailpage after login

$
0
0

Hi Forum How come my app crashes after tapping the Log in

Here is my code for log in

`public partial class LoginPage : ContentPage
{
public LoginPage ()
{
InitializeComponent ();
BackgroundColor = Color.FromRgb(51,10,120);
NavigationPage.SetHasNavigationBar(this, false);
}

    async void OnLoginButtonClicked(object sender, EventArgs e)
    {
        var user = new User
        {
            Username = usernameEntry.Text,
            Password = passwordEntry.Text
        };

        var isValid = AreCredentialsCorrect(user);
        if (isValid)
        {
            App.IsUserLoggedIn = true;
            App.Current.MainPage = new MainPage();
            //Navigation.InsertPageBefore(new MainPage(), this);
            //await Navigation.PopAsync();
        }
        else
        {
            messageLabel.Text = "Login failed";
            passwordEntry.Text = string.Empty;
        }
    }

    bool AreCredentialsCorrect(User user)
    {
        return user.Username == Constants.Username && user.Password == Constants.Password;
    }
}`

Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>