I'm working on relatively outdated asp.net website (not web app) project.
I was asked to do some changes in the master page, which I did and it works fine when I run locally.
The error is happening when I want to build and publish the website, I'm getting error message that the name 'XXX' does not exist in the current context, although I'm able to access the control by their id in the code behind file.
This is what I have:
<div class="mainLogin">
<asp:TextBox ID="loginEntry" CssClass="login-name" placeholder="Username or email address" runat="server" ></asp:TextBox>
<asp:TextBox ID="passwordEntry2" CssClass="login-password" placeholder="Password" runat="server" TextMode="Password"></asp:TextBox>
<div class="login-remember-me">
<input type="checkbox" runat="server" id="chkRememberme2" />
<label>Remember me</label>
</div>
<button class="login-submit orange-button" runat="server" OnServerClick="btnLogin_OnServerClick" ID="btnLogin">Login <div class="arrow-right"></div></button>
</div>
It all works fine when I run that locally but when I try to build and publish this is the error I'm getting:
The event which is happening in the code file:
protected void btnLogin_OnServerClick(object sender, EventArgs e)
{
if (loginEntry.Text != string.Empty && passwordEntry2.Text != string.Empty)
{
logInProc(loginEntry.Text, passwordEntry2.Text, chkRememberme2.Checked);
}
}
And the master page directive:
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="MasterPage" %>
Code file:
public partial class MasterPage : ParentMasterPage
{
//master page code here
}
If I remove those new controls and new functionality, I'm able to run the project without any issue.
Any idea what is wrong?
Try To Clean the solution then rebuilt it
if not work then go to deisgner.cs page then check that the entry for above text boxes are there or not? fix it there
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.