Create a windows application that contains two TextBox objects and two Button objects. One of the TextBox objects and one of the buttons are initially invisible. The first textbox should be used to input a password. The textbox should be masked to some character of your choice so that the characters entered by the user are not seen on the screen. When the user clicks the first button, the second TextBox object and button object should be displayed with a prompt asking the user to reenter his or her password. Now the user clicks the second button, have the application compare the values entered to make sure they are the same. Display an appropriate message indicating whether they are the same.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace PasswordProject
{
public partial class frmPasswordProject : Form
{
public frmPasswordProject()
{
InitializeComponent();
}
/// <summary>
/// When the user clicks the first button, the second TextBox object and button object should be
/// displayed with a prompt asking the user to reenter his or her password.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnDisplay_Click(object sender, EventArgs e)
{
lblYourPassword.Visible = true;
txtYourPassword.Visible = true;
btnCheck.Visible = true;
}
/// <summary>
/// Now the user clicks the second button, have the application compare the values
/// entered to make sure they are the same. Display an appropriate message indicating whether they are the same.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnCheck_Click(object sender, EventArgs e)
{
if (txtSecretPassword.Text == txtYourPassword.Text)
{
MessageBox.Show("The passwords are the same.");
}
else {
MessageBox.Show("The passwords are NOT the same.");
}
}
}
}
Comments
Leave a comment