RT!
我在LinkManage.cs这个类中已经定义好了静态的LinkInsert方法,在LinkCreate.aspx.cs中通过转换定义也能定位到LinkManage.cs中的LinkInsert方法,可在调试时总是这个编译错误。
错误信息:
“/PersonalWebsite”应用程序中的服务器错误。
--------------------------------------------------------------------------------
编译错误
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。
编译器错误信息: CS0117: “LinkManage”并不包含“LinkInsert”的定义
源错误:
行 52: }
行 53: }
行 54: ret=LinkManage.LinkInsert(this.txtName.Text, this.txtURL.Text, "upLoad\\" + fileName);
行 55: if (ret)
行 56: {
源文件: e:\xiewentong\PersonalWebsite\LinkCreate.aspx.cs 行: 54
原代码如下:
1) LinkManage.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 DAONewsTableAdapters;
namespace personalWebsite.Business
{
/// <summary>
/// LinkManage 的摘要说明
/// </summary>
public class LinkManage
{
public LinkManage()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public static bool LinkInsert(string name,string URL, string ImageURL )
{
SP_LinkSelectAllTableAdapter all = new SP_LinkSelectAllTableAdapter();
all.Insert(name, URL, ImageURL);
return true;
}
}
}
2)LinkCreate.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 personalWebsite.Business;
public partial class LinkCreate : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Redirect("LinkManage.aspx");
}
protected void Button1_Click(object sender, EventArgs e)
{
string sPath="";
string fileName="";
bool ret;
if (this.FileUpload1.HasFile)
{
try
{
sPath =Server.MapPath("upLoad");
//String sDir = DateTime.Now.ToString("yyyy-MM");
//sPath = sPath + "\\" + sDir;
//if (!Directory.Exists(sPath))
//{
// Response.Write("00000000");
// Response.Write(sPath);
// Directory.CreateDirectory(sPath);
// }
fileName = FileUpload1.FileName;
FileUpload1.SaveAs(sPath + "\\"+fileName);
}
catch(Exception ex)
{
lblError.Text = ex.Message;
}
}
ret=LinkManage.LinkInsert(this.txtName.Text, this.txtURL.Text, "upLoad\\" + fileName);
if (ret)
{
Response.Write("添加链接成功!");
}
}
}
[此贴子已经被作者于2007-8-9 19:30:26编辑过]