C# 我的代码中有ScriptManager错误吗?

C# 我的代码中有ScriptManager错误吗?,c#,asp.net-2.0,scriptmanager,C#,Asp.net 2.0,Scriptmanager,我正在尝试使用脚本管理器检查我的路径,我的代码在App_代码中这是我的代码: public ReportDocument ReportCon(string path) { ReportDocument cryRpt = new ReportDocument(); ConnectionInfo info = new ConnectionInfo(); TableLogOnInfo crtableLogoninfo = new TableLog

我正在尝试使用脚本管理器检查我的路径,我的代码在App_代码中这是我的代码:

public ReportDocument ReportCon(string path)
    {
        ReportDocument cryRpt = new ReportDocument();
        ConnectionInfo info = new ConnectionInfo();
        TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
        Tables CrTables;

        info.ServerName = "192.168.1.200";
        info.DatabaseName = "Track4L";
        info.UserID = "Developers";
        info.Password = "dev01@pps";
        ScriptManager.RegisterStartupScript(this, typeof(Page), "test", "alert('" + path + "');", true);
        cryRpt.Load(path);

        CrTables = cryRpt.Database.Tables;
        foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
        {
            crtableLogoninfo = CrTable.LogOnInfo;
            crtableLogoninfo.ConnectionInfo = info;
            CrTable.ApplyLogOnInfo(crtableLogoninfo);
        }
        return cryRpt;
    }
但我得到以下错误:

 Error The best overloaded method match for 'System.Web.UI.ScriptManager.RegisterStartupScript(System.Web.UI.Page, System.Type, string, string, bool)' has some invalid arguments   D:\DMS\DocumentManagement\Track4L\App_Code\ReportConnection.cs  27  13  D:\...\Track4L\

我不知道这个问题将如何解决

我认为您正在将此方法的第一个参数传递给类的对象。将调用页的对象传递给它。我希望你的问题会得到解决

    public ReportDocument ReportCon(System.Web.UI.Page myPage, string path)
    {
       // your code
       ScriptManager.RegisterStartupScript(myPage, typeof(Page), "test", "alert('" + path + "');", true);

    }

我认为您正在将此方法的第一个参数传递给类的对象。将调用页的对象传递给它。我希望你的问题会得到解决

    public ReportDocument ReportCon(System.Web.UI.Page myPage, string path)
    {
       // your code
       ScriptManager.RegisterStartupScript(myPage, typeof(Page), "test", "alert('" + path + "');", true);

    }

只是一个猜测,但既然你说上面的代码在你的App_code文件夹中,我打赌
并不是指
System.Web.UI.Page
@Tim,那么我要做的就是做@Adil推荐的事情。您需要更新代码中调用
ReportCon
以获取
Page
参数和path参数的所有位置。只是猜测一下,但既然您说上面的代码在您的App\u code文件夹中,我打赌
这个
不是指
System.Web.UI.Page
@Tim,那么我必须做什么,做@Adil推荐的事情。您需要更新代码中调用
ReportCon
以获取
Page
参数和path参数的所有位置。亲爱的,但它不是一个页面,而是一个.cs文件,存在于应用程序代码中。我要做的是告诉我解决方案您将从您的页面调用此方法?如果是,那么在这个方法中传递你的页面对象,比如ReportDocument ReportCon(这是“你想要的路径”),但是我在许多其他页面中调用这个函数,它们只接受一个参数,即“path”,那么它们呢?你从其他页面进行调用时没有确保它工作吗?试试这个,它可能会工作Page.ClientScript.RegisterStartupScript(typeof(Page),“OnLoad”,“alert('OK');”,true);i get Error非静态字段、方法或属性'System.Web.UI.Page.ClientScript.get'D:\DMS\DocumentManagement\Track4L\App\U Code\ReportConnection.cs 27 13 D:\…\Track4L\Dear需要对象引用,但它不是一个页面,而是一个存在于App\U代码中的.cs文件。我要做的是告诉我解决方案您将从您的页面调用此方法?如果是,那么在这个方法中传递你的页面对象,比如ReportDocument ReportCon(这是“你想要的路径”),但是我在许多其他页面中调用这个函数,它们只接受一个参数,即“path”,那么它们呢?你从其他页面进行调用时没有确保它工作吗?试试这个,它可能会工作Page.ClientScript.RegisterStartupScript(typeof(Page),“OnLoad”,“alert('OK');”,true);i get Error非静态字段、方法或属性'System.Web.UI.Page.ClientScript.get'D:\DMS\DocumentManagement\Track4L\App\U Code\ReportConnection.cs 27 13 D:\…\Track4L'需要对象引用\