ASPNET:确保此代码文件中定义的类与'inherits'属性匹配

Han*_*ome 4 c# asp.net

namespace ASPMultilingual { 
public partial class _Default : System.Web.UI.Page
{
    ResourceManager rm;
    CultureInfo ci;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["Lang"] == null) { 
            Session["Lang"] ="en-US";
        }

        if (!IsPostBack)
        {
            LoadString();

        }

    }

    private void LoadString(){

        Thread.CurrentThread.CurrentCulture = new CultureInfo(Session["Lang"].ToString());
        //rm = new ResourceManager("ASPMultilingual.App_GlobalResources.Lang", Assembly.GetExecutingAssembly());
        ResourceManager rm = new ResourceManager("ASPMultilingual.Lang", System.Reflection.Assembly.Load("ASPMultilingual"));
        ci = Thread.CurrentThread.CurrentCulture;


        btnLogIn.Text = rm.GetString("Login", ci);
    }

    protected void btnLogIn_Click(object sender, EventArgs e)
    {
        string ID = Request.Form["txtID"];
        String password = Request.Form["txtPassword"];
        string strConString = ConfigurationManager.ConnectionStrings["SOConnectionString"].ConnectionString;
        OleDbConnection conn = new OleDbConnection(strConString);
        OleDbCommand cmd = new OleDbCommand("SELECT * FROM USERMASTER", conn);

        try
        {

            conn.Open();
            OleDbDataReader dr;

            dr = cmd.ExecuteReader();
            while (dr.Read()) {
                string testposition = dr["UserPosition"].ToString();
                string dataID = dr["UserId"].ToString();
                string dataPass = dr["UserPwd"].ToString();
                if (dataPass == txtPassword.Text && dataID == txtID.Text)
                {
                    Session["User_Position"] = testposition;
                    Response.Redirect("Default2.aspx");
                }
                else {

                    lblError.Text = "Invalid account! Please Enter again!";
            }

            }


        }
        catch (Exception ex)
        {
            txtID.Text = "ex";
            lblError.Text = ex.ToString();


        }
        finally
        {
            conn.Close();
            conn.Dispose();
        }


        //Response.Redirect("Default2.aspx");
        //ClientScript.RegisterStartupScript(this.GetType(), "yourMessage", "alert('" + ID + " " + password + "');", true);

    }

    protected void ddLang_SelectedIndexChanged(object sender, EventArgs e)
    {
        Session["Lang"] = ddLang.SelectedValue;
        LoadString();
    }
}
}
Run Code Online (Sandbox Code Playgroud)

代码运行正常,直到我在代码顶部添加命名空间然后它抛出错误.

编译错误说明:在编译服务此请求所需的资源期间发生错误.请查看以下特定错误详细信息并相应地修改源代码.

编译器错误消息:

ASPNET:确保此代码文件中定义的类与'inherits'属性匹配,并且它扩展了正确的基类(例如Page或UserControl).

源错误:第19行:公共部分类_Default

Mai*_*mad 9

您需要在inherits属性中的aspx页面中的类名之前添加命名空间.

<%@ Page Title="Some Title" Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="ASPMultilingual._Default" %>
Run Code Online (Sandbox Code Playgroud)