简体   繁体   中英

Name doesn't exist in the current context

I keep getting the error

The name '****' does not exist in the current context

when trying to start the application. No idea why. No spelling error, I've checked it over and over and I'm not sure if I've missed something out? The error occurs for TxtUsername, TxtPassword and LblMessage Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Configuration;

namespace MusicShop.Admin
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void BtnLogin_Click(object sender, EventArgs e)
        {
            string Username = WebConfigurationManager.AppSettings["AdminLoginID"];
            string Password = WebConfigurationManager.AppSettings["AdminPassword"];

            if (TxtUsername.Text == Username && TxtPassword.Text == Password)
            {
                Session["MusicShopAdmin"] = "MusicShopAdmin";
                Response.Redirect("#/Admin/AddNewSong.aspx");
            }
            else
            {
                LblMessage.Text = "Wrong Username or Password";
            }
        }
    }
}

Thanks for the help, I did look into it and it was a fault of my own, I had originally named the Web form LoginAdmin, then renamed it to Login, so to my own surprise I had just deleted it and made a new web form and copy & pasted the code and it worked...

Thanks for all the suggestions though, I'll keep them in mind in the future!

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM