I am testing out a webform to save strings from a textbox. The program stops running when I press a button programmed to save the info into an array. Here's the error:
System.NullReferenceException occurred HResult=0x80004003 Message=Object reference not set to an instance of an object. Source=TS_Webform StackTrace: at TS_Webform.Forms.Login.registerUser() in C:\Users\k20\Source\Repos\TS_Webform\TS_Webform\Forms\Login.aspx.cs:line 105 at TS_Webform.Forms.Register2.Button1_Click(Object sender, EventArgs e) in C:\Users\k20\Source\Repos\TS_Webform\TS_Webform\Forms\Register2.aspx.cs:line 25
heres the method that it the message directs me to:
public static void registerUser()
{
User newUser = new User();
Register2 register2 = new Register2();
newUser.strName = register2.TextBox1.Text;//Stops here
newUser.strPW = register2.TextBox2.Text;
//newUser.strEmail = textBox3.Text;
newUser.strPhone = register2.TextBox3.Text;
newUser.strHas = register2.TextBox4.Text;
newUser.strNeeds = register2.TextBox5.Text;
userArray[I(userArray)] = newUser;
}
I tried numerous things like changing the Textbox-declaration line on Register2.aspx.designer.cs from protected to public and public static and neither has worked.