【问题标题】:ScriptManager Error in my code?我的代码中有 ScriptManager 错误?
【发布时间】:2012-04-19 04:58:04
【问题描述】:

我正在尝试使用脚本管理器检查我的路径,我的代码在 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\

不知道这个问题怎么解决

【问题讨论】:

  • 只是猜测,但既然你说上面的代码在你的 App_Code 文件夹中,我敢打赌this 不是指System.Web.UI.Page
  • @Tim 那么亲爱的我该做什么
  • 按照@Adil 的建议去做。您需要更新代码中调用 ReportCon 的所有位置,以获取 Page 参数和路径参数。

标签: c# asp.net-2.0 scriptmanager


【解决方案1】:

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

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

    }

【讨论】:

  • 亲爱的,但它不是一个页面,它是一个存在于 App_Code 中的 .cs 文件。我必须做什么告诉我解决方案
  • 您会从您的页面调用此方法吗?如果是,则在此方法中传递您的页面对象,例如 ReportDocument ReportCon(this, "your desired path")
  • 但是在许多其他页面中调用这个函数,他们只接受一个参数,即“路径”他们呢
  • 您是否在未确保其正常工作的情况下从其他页面拨打电话?试试这个它可能会工作 Page.ClientScript.RegisterStartupScript(typeof(Page), "OnLoad", "alert('OK');",true );
  • 我收到错误非静态字段、方法或属性“System.Web.UI.Page.ClientScript.get”需要对象引用 D:\DMS\DocumentManagement\Track4L\App_Code\ReportConnection .cs 27 13 D:\...\Track4L\
猜你喜欢
  • 2010-11-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-01-13
  • 1970-01-01
相关资源
最近更新 更多