Reputation: 1227
I am sure this question comes up a lot, but I didn't find an answer in your archives. Here is my ASP code:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="RCC_ChangePassword.ascx.cs" Inherits="Regal.Web._Tester.RCC.RCC_ChangePassword" %>
<div id="modal-password-change">
<div class="modal-contents">
<h1>Change Password</h1>
<div class="intro">Use the form below to change the password for your RCC account. Use the new password next time you log in.</div>
<asp:Label ID="CurPass" Text="Current Password" runat="server"></asp:Label>
<asp:Textbox id="CurrentPass" runat="server" CssClass="required"></asp:Textbox>
<asp:Label ID="NwPass" Text="New Password*" runat="server"></asp:Label>
<asp:Textbox id="NewPass" runat="server" CssClass="required"></asp:Textbox>
<asp:Label ID="CnfPass" Text="Confirm Password" runat="server"></asp:Label>
<asp:Textbox id="ConfirmPass" runat="server" CssClass="required"></asp:Textbox>
<h4>Your password must include ALL of the following</h4>
<ul class="notes">
<li>At least 8 characters (not more than 16 characters)</li>
<li>At least one number</li>
</ul>
<asp:Button ID="submit" Cssclass="btn blue wide" runat="server" Text="Save Changes" OnClick="btnSubmit_click"></asp:Button>
</div>
</div><!-- #modal-password-change .modal -->
And here is the line that I am getting the error on:
// Change actual password for the new password
String testPass1 = NewPass.Text;
if (regalMemberRepo.ChangePassword(oUser.Email, oUser.Password, testPass1))
can you see anything odd about my code? Thank you in advance.
Upvotes: 1
Views: 16450
Reputation: 177
After adding a TextBox
programmatically I received this error when trying to access its Text
property. Here's a quick function I used to access it:
private string GetTextFromTextBox(string strTextBoxName)
{
Control[] txtBox = Controls.Find(strTextBoxName, true);
if (txtBox != null)
{
return txtBox[0].Text;
}
else
{
return null;
}
}
Upvotes: 0
Reputation: 15253
This happens to me often with VS. Take a look in the designer file and see if VS created an entry in there for the text box? Make sure you don't have another file somewhere with a similar declaration.
Many times, best way to fix this is to delete, re-create and re-name the form. We're not supposed to edit the designer file ourselves.
Upvotes: 4