I got almost everything to work but I can not enter any text in the Login or Pas
ID: 3878606 • Letter: I
Question
I got almost everything to work but I can not enter any text in the Login or Password boxes. Would you please look at my code and help me. Thank You, GOD Bless.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace _15._8LoginUserControl
{
public partial class LoginForm : Form
{
public LoginForm()
{
InitializeComponent();
}
private void btnLogin_Click(object sender, EventArgs e)
{
string uName = loginPasswordUserControl1.Logon;
string pWord = loginPasswordUserControl1.Password;
string btnLogin = "User Name:" + uName + " Password is:" + pWord;
MessageBox.Show(btnLogin, "Info",MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
----------------------------------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace _15._8LoginUserControl
{
public partial class LoginPasswordUserControl : UserControl
{
public string Logon
{
get
{
return tbLogin.Text.Trim();
}
}
public string Password
{
get
{
return tbPassword.Text.Trim();
}
}
private void tbLogin_TextChanged(object sender, EventArgs e)
{
}
public LoginPasswordUserControl()
{
InitializeComponent();
}
}
}
Explanation / Answer
You have created a class loginPasswordUserControl and a windows form above.
Now to get the data the from below code, you need to REMOVE THE 1 from loginPasswordUserControl1 and make it
loginPasswordUserControl.Logon and same goes with loginPasswordUserControl.Password
other wise you need to make an object of class loginPasswordUserControl.
In this way you are good to go with your code
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.