我的代码中的ScriptManager错误?

时间:2012-04-19 04:58:04

标签: c# asp.net-2.0 scriptmanager

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

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\

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

1 个答案:

答案 0 :(得分:3)

我认为你将这个方法的第一个参数传递给你的类的对象。将它传递给调用页面的对象。我希望你的问题能够得到解决。

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

    }