Question

What am I doing wrong? I get this error: "The name 'LoginPasswordUserControl' does not exist in...

What am I doing wrong?

I get this error:

"The name 'LoginPasswordUserControl' does not exist in the current context"

I have a user control, here is the code:

using System.Windows.Forms;
//Define the namespace to make the user control.
//namespace to hold the application
namespace LoginPasswordUser
{
//Define the class to make the user control.  
//Class to define the control  
public partial class LoginPasswordUserControl : UserControl
{
//Define the read-only properties to get the username and the password from the user control. //Define the property for the username. //property to read username  
public string Login { get { return loginTextBox.Text.Trim(); } }
// Define the property for the password. //property to read password  
public string Password { get { return passwordTextBox.Text.Trim(); } }
//Define the constructor to initialize the GUI of the user control.  
/* Constructor to initialize the user control */
public LoginPasswordUserControl() { InitializeComponent(); }
}
}

I also have my main class, here is that code:

namespace testing
{
//Define the class to make the application. //class to define the form  
public partial class LoginForm : Form
{
//Define the constructor to initialize the GUI of the form.
/*Constructor to initialize the GUI of the form */
public LoginForm() { InitializeComponent(); }
//Define the Click event of the button to process the username and the password.  
/* Method to define the Click event of the Button */
private void btnGetDetails_Click(object sender, EventArgs e)
{
//Get the value of the username and password fields in the strings.  
//get the username and password  
string uName = LoginPasswordUserControl.Login;
string pWord = LoginPasswordUserControl.Password;
//Get a new string by concatenating the username and the password.  
//make a single string from the username and
//password  
string logDetail = "User Name: " + uName + "\nPassword is: " + pWord;
//Show the username and the password in the new MessageBox. //show the details in a //MessageBox  
MessageBox.Show(logDetail, "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}

PLEASE HELP!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hey, In the main function you directly used "LoginPasswordUserControl" class without specifying its namespace name. Whenever you want to use a class which is present in another namespace , you should mention the namespace name also.You can use the above function like this "LoginPasswordUser.LoginPasswordUserControl". Even after this change you will get one more error because you used the class "LoginPasswordUserControl" without creating an object of it. First create an object , then use it.

One suggestin from my side . For best free c# tutorials watch kudvent channel on youtube..

Add a comment
Know the answer?
Add Answer to:
What am I doing wrong? I get this error: "The name 'LoginPasswordUserControl' does not exist in...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • What am I doing wrong on this? Chapter 17, Problem 3E // Michael Cole // 6/28/2017...

    What am I doing wrong on this? Chapter 17, Problem 3E // Michael Cole // 6/28/2017 // Name spaces for application using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; namespace Week8 {     public partial class Form1: Form     {         // Get the location where the data file would be created         string fileLoc = Application.StartupPath +             "\\Datafile.txt";         /* Constructor of the class to create the GUI of the form */         public Form1()        ...

  • Hi everyone, For my Assignment I have to use C# in order to create a validation...

    Hi everyone, For my Assignment I have to use C# in order to create a validation form and include the following things to register and validate: Email Address, Username, Password, Retype Password, and a Submit Button. I have figured out some of the code for the Email Address validation: 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 Validation4 {     public partial class Form1 : Form     {        ...

  • Written in Java I have an error in the accountFormCheck block can i get help to...

    Written in Java I have an error in the accountFormCheck block can i get help to fix it please. Java code is below. I keep getting an exception error when debugging it as well Collector.java package userCreation; import java.io.IOException; import java.net.URL; import java.util.ResourceBundle; import java.util.regex.Matcher; import java.util.regex.Pattern; import javafx.event.ActionEvent; import javafx.fxml.*; import javafx.scene.*; import javafx.scene.control.*; import javafx.scene.text.Text; import javafx.stage.*; public class Controller implements Initializable{ @FXML private PasswordField Password_text; @FXML private PasswordField Confirm_text; @FXML private TextField FirstName_text; @FXML private TextField LastName_text;...

  • How can I add this function to my C# code?: Validate that if the user clicks...

    How can I add this function to my C# code?: Validate that if the user clicks the “OK” button, a “Seating Category” is selected, and at least one ticket is being purchased. If not, pop-up a dialog box asking the user to enter the needed data for the transaction. What we want to avoid is depicted in See Figure 3. Figure 3: This code asks for a seating category to be selected, how many tickets to be purchased, and if...

  • An application contains the Structure statement shown here. Structure MyFriend Public strName As String Public strBirthday...

    An application contains the Structure statement shown here. Structure MyFriend Public strName As String Public strBirthday As String End Structure Create a VB.Net Windows Form application named MyFriend_YourName. Change the name property of your form to frmMain. Add the MyFriend Structure to the public class frmMain. Create 2 text boxes txtName and txtBirthday, and a button with the name property changed to btnExecute and the text property changed to Execute. In the button click event, write a Dim statement that...

  • Requirements I have already build a hpp file for the class architecture, and your job is to imple...

    Requirements I have already build a hpp file for the class architecture, and your job is to implement the specific functions. In order to prevent name conflicts, I have already declared a namespace for payment system. There will be some more details: // username should be a combination of letters and numbers and the length should be in [6,20] // correct: ["Alice1995", "Heart2you", "love2you", "5201314"] // incorrect: ["222@_@222", "12306", "abc12?"] std::string username; // password should be a combination of letters...

  • Using C# Language Develop a Visual C# .NET application that performs a colour control operation. The...

    Using C# Language Develop a Visual C# .NET application that performs a colour control operation. The main form contains a reset button and sets the form's background colour according to the colour values indicated by the colour control objects. Each colour control object is controlled by a corresponding colour control form which provides a progress bar to show the value (in the range 0 to 255) of the corresponding colour control object. The user can click the increase (+) or...

  • I am currently doing homework for my java class and i am getting an error in...

    I am currently doing homework for my java class and i am getting an error in my code. import java.util.Scanner; import java.util.Random; public class contact {       public static void main(String[] args) {        Random Rand = new Random();        Scanner sc = new Scanner(System.in);        System.out.println("welcome to the contact application");        System.out.println();               int die1;        int die2;        int Total;               String choice = "y";...

  • Visual Basic 2015: Extra 18-1 Use inheritance with the Inventory Maintenance Application Source Code: 1. frmNewItem.vb...

    Visual Basic 2015: Extra 18-1 Use inheritance with the Inventory Maintenance Application Source Code: 1. frmNewItem.vb Public Class frmNewItem Public InvItem As InvItem Private Sub frmNewItem_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.LoadComboBox() End Sub Private Sub LoadComboBox() cboSizeOrManufacturer.Items.Clear() If rdoPlant.Checked Then cboSizeOrManufacturer.Items.Add("1 gallon") cboSizeOrManufacturer.Items.Add("5 gallon") cboSizeOrManufacturer.Items.Add("15 gallon") cboSizeOrManufacturer.Items.Add("24-inch box") cboSizeOrManufacturer.Items.Add("36-inch box") Else cboSizeOrManufacturer.Items.Add("Bayer") cboSizeOrManufacturer.Items.Add("Jobe's") cboSizeOrManufacturer.Items.Add("Ortho") cboSizeOrManufacturer.Items.Add("Roundup") cboSizeOrManufacturer.Items.Add("Scotts") End If End Sub Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click If IsValidData() Then InvItem = New InvItem(CInt(txtItemNo.Text),...

  • Theres an error on The bolded line, what am I doing wrong? #include <iostream> //just for...

    Theres an error on The bolded line, what am I doing wrong? #include <iostream> //just for writing and reading from console #include <fstream> //this one to deal with files, read and write to text files using namespace std; int main() { //first thing we need to read the data in the text file //let's assume we have the reading in a text file called data.txt //so, we need a stream input variable to hold this data ifstream infile; //now we...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT