简体   繁体   English

当前上下文中不存在名称

[英]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: TxtUsername、TxtPassword 和 LblMessage 代码发生错误:

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...谢谢你的帮助,我确实查了一下,是我自己的问题,我原来把Web表单命名为LoginAdmin,然后将其重命名为Login,没想到我刚刚删除了它并创建了一个新的Web表单并复制并粘贴代码,它起作用了......

Thanks for all the suggestions though, I'll keep them in mind in the future!感谢您的所有建议,我会在将来记住它们!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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