i'm working on ASP.net web site , in one of my forms i added HTML control , while using that control from the code behind file i got wiered error which i can't understand .
<table style="width: 100%;" class="table-responsive">
<tr>
<td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<input id="UserName" runat="server" type="text" class="form-control" placeholder="Username" required="required"/>
</td>
</tr>
<tr>
codeBehind file :
protected void Page_Load(object sender, EventArgs e)
{
}
public void signupData()
{
string s = UserName.text;
}
error image
This message can occur when two front end files reference a single back end class.
For example you could have two front end files called: signup.ascx
and signupLight.ascx
These files then reference a shared back-end code file: signup.ascx.cs
The problem arises where you add a control to one of the front end files but not the other.
e.g. The UserName HtmlInputText
control in your example could exist in signup.ascx
but not signupLight.ascx
so that when you reference it in signup.ascx.cs
it is showing that one of the references is missing.
Another example could happen if you make a backup of the front end file by making a copy with a different filename but not adding the .exclude
file extension. This will then interfere with trying to reference new front end controls in the back end, as the codefile tag is still pointing at the live code behind.
Unfortunately visual studio highlights this as needing to switch context and showing the names of two identical projects rather than the actual file where the reference originated, so you may have to do a search in your project for the backend filename to find all the active front end files where they are referenced.
Visual Studio was giving me the same error. Made sure no front end files were referencing same back end files.
For me the fix was changing CodeFile
to CodeBehind
in the associated aspx.cs file. That resolved the error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With