簡體   English   中英

當前上下文中不存在名稱

[英]Name doesn't exist in the current context

我不斷收到錯誤

當前上下文中不存在名稱“****”

嘗試啟動應用程序時。 不知道為什么。 沒有拼寫錯誤,我已經一遍又一遍地檢查了它,但我不確定我是否遺漏了什么? 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";
            }
        }
    }
}

謝謝你的幫助,我確實查了一下,是我自己的問題,我原來把Web表單命名為LoginAdmin,然后將其重命名為Login,沒想到我剛剛刪除了它並創建了一個新的Web表單並復制並粘貼代碼,它起作用了......

感謝您的所有建議,我會在將來記住它們!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM