ASPNET:确保此代码文件中定义的类与"inherits"属性匹配 [英] ASPNET: Make sure that the class defined in this code file matches the 'inherits' attribute
问题描述
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();
}
}
}
代码运行良好,直到我在代码顶部添加名称空间,然后将其抛出错误.
The code running fine until I wich to add namespace on top of the code then its throw me the error.
编译错误说明:编译服务该请求所需的资源期间发生错误.请查看以下特定的错误详细信息,并适当地修改您的源代码.
Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
编译器错误消息:
ASPNET:确保此代码文件中定义的类与'inherits'属性,并扩展了正确的基类(例如页面或UserControl).
ASPNET: Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl).
源错误:第19行:公共局部类_Default
Source Error: Line 19: public partial class _Default
推荐答案
您需要在 inherits
属性的aspx页面中的类名称之前添加名称空间.
You need to add namespace before class name in aspx page in inherits
attribute.
<%@ Page Title="Some Title" Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="ASPMultilingual._Default" %>
这篇关于ASPNET:确保此代码文件中定义的类与"inherits"属性匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!