2012-04-19 51 views
0

我試圖檢查使用腳本管理我的路,我的代碼是在App_Code文件這裏是我的代碼:ScriptManager在我的代碼錯誤?

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 = "[email protected]"; 
     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; 
    } 

,但我得到以下錯誤「錯誤「的System.Web.UI的最佳重載的方法匹配。 ScriptManager.RegisterStartupScript(System.Web.UI.Page,System.Type,string,string,bool)'有一些無效參數D:\ DMS \ DocumentManagement \ Track4L \ App_Code \ ReportConnection.cs 27 13 D:... \ Track4L \」

我不知道這個問題怎麼會solved.tell我什麼在我的代碼是問題

+0

只是一個猜測,但既然你說上面的代碼是在你的App_Code文件夾,我打賭'this'並不是指一個'System.Web.UI.Page'。 – Tim 2012-04-19 05:03:51

+0

@Tim然後我必須做的親愛的 – 2012-04-19 05:14:04

+0

做什麼@Adil推薦。您需要更新代碼中的所有位置,其中'ReportCon'被調用以獲取'Page'參數和路徑參數。 – Tim 2012-04-19 05:15:20

回答

3

我覺得你經過的g這個方法的第一個參數是你的類的對象。將它傳遞給調用頁面的對象。我希望你的問題能夠解決。

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

    } 
+0

親愛的,但它不是一個頁面,它是一個.cs文件,它是App_Code中的prestent。我必須告訴我的解決方案 – 2012-04-19 05:07:50

+0

你會從你的頁面調用這個方法嗎?如果是的話,然後像ReportDocument ReportCon這樣傳遞你的頁面對象(這個,「你想要的路徑」) – Adil 2012-04-19 05:09:46

+0

但是我們在很多其他頁面調用這個函數,並且它們只接受一個參數,就是「路徑」他們怎麼樣 – 2012-04-19 05:11:24