vs2005中出现没有找到适合的方法来重写
编译错误说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。
编译器错误信息: CS0115: “ASP.like_aspx.GetTypeHashCode()”: 没有找到适合的方法来重写
源错误:
行 370:
行 371: [System.Diagnostics.DebuggerNonUserCodeAttribute()]
行 372: public override int GetTypeHashCode() {
行 373: return -2143806675;
行 374: }
源代码:
like.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="like.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:CheckBoxList ID="CheckBoxList1" runat="server" Height="160px" RepeatColumns="2"
Style="left: 230px; position: relative; top: 122px" Width="236px" OnSelectedIndexChanged="CheckBoxList1_SelectedIndexChanged">
</asp:CheckBoxList></div>
</form>
</body>
</html>
like.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
namespace WebSite1
{
public class like : System.Web.UI.Page
{
protected System.Web.UI.WebControls.CheckBoxList CheckBoxList1;
protected void Page_Load(object sender, System.EventArgs e)
{
SqlConnection con = DB.createConnection();
con.Open();
SqlCommand cmd = new SqlCommand("select * from personlike", con);
SqlDataReader sdr = cmd.EndExecuteReader();
this.CheckBoxList1.DataTextField = "likeContent";
this.CheckBoxList1.DataValueField = "id";
this.CheckBoxList1.DataSource = sdr;
this.CheckBoxList1.DataBind();
sdr.close();
con.Close();
}
}
}
DB.cs
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
/// <summary>
/// DB 的摘要说明
/// </summary>
///
namespace WebSite1
{
public class DB
{
public DB()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public static SqlConnection createConnection()
{
System.Data.SqlClient.SqlConnection con = new SqlConnection("server=(local);database=login;uid=sa;pwd=;");
return con;
}
}
} --------------------编程问答-------------------- <%@ Page Language="C#" AutoEventWireup="true" CodeFile="like.aspx.cs" Inherits="Default2" %>
Inherits="Default2" 换成 Inherits="like" --------------------编程问答-------------------- like.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="like.aspx.cs" Inherits="like" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
你这是类名不一致造成的 --------------------编程问答-------------------- <%@ Page Language="C#" AutoEventWireup="true" CodeFile="like.aspx.cs" Inherits="Default2" %>
public class like : System.Web.UI.Page
把第一句改成
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="like.aspx.cs" Inherits="like" %>
绝对就OK了 --------------------编程问答--------------------
对,我以前也遇到过这样的问题
就是类名不一致 --------------------编程问答-------------------- 父类有没有这个方法? --------------------编程问答--------------------
补充:.NET技术 , ASP.NET