I've had a look at similar questions (1,2) but they don't appear to provide me a solution :S
I'm trying to add an extra field to a registration form that is already pre-built (i.e. comes with) in ASP.Net Web Form.
What I'm doing is, in the Register.aspx.cs
backend I try to obtain the value txtCompanyInput.Text();
:
protected void RegisterUser_CreatedUser(object sender, EventArgs e)
{
... // some code here
String CompanyName = txtCompanyInput.Text();
... // other code here
Response.Redirect(continueUrl);
}
The Register.aspx
itself looks like so:
...
<li>
<asp:Label runat="server" AssociatedControlID="ConfirmPassword">
Confirm password</asp:Label>
<asp:TextBox runat="server" ID="ConfirmPassword" TextMode="Password" />
<asp:RequiredFieldValidator runat="server" ControlToValidate="ConfirmPassword"
CssClass="field-validation-error" Display="Dynamic"
ErrorMessage="The confirm password field is required." />
<asp:CompareValidator runat="server" ControlToCompare="Password"
ControlToValidate="ConfirmPassword"
CssClass="field-validation-error" Display="Dynamic"
ErrorMessage="The password and confirmation password do not match." />
</li>
<li>
<asp:TextBox ID="txtCompanyInput" runat="server"></asp:TextBox>
</li>
...
When I try to build the project I run into an error saying:
Error 1 The name 'txtCompanyInput' does not exist in the current context c:\users\...\Account\Register.aspx.cs 62 34 ProjectTest
Is there a reason why I'm not able to reference the txtCompanyName
field in the backend?