2011-04-15 35 views
0

這工作:可以不加控制,用戶控件

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Comments.ascx.cs" Inherits="Controls_Comments" %> 

Add comment 

但這:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Comments.ascx.cs" Inherits="Controls_Comments" %> 

Add comment 
<asp:Button runat="server" ID="lol" /> 

拋出這個錯誤我以前從未見過:

Compilation Error 

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS1502: The best overloaded method match for 'System.Web.UI.Control.ApplyStyleSheetSkin(System.Web.UI.Page)' has some invalid arguments 

Source Error: 


Line 190:   #line hidden 
Line 191:   this.lol = @__ctrl; 
Line 192:   @__ctrl.ApplyStyleSheetSkin(this.Page); 
Line 193:    
Line 194:   #line 5 "C:\inetpub\wwwroot\ScirraNew\Controls\Comments.ascx" 

Source File: c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\scirranew\3a1c901c\f2f0205e\App_Web_comments.ascx.cc671b29.aem6dvrt.0.cs Line: 192 

任何幫助表示讚賞,我不能在谷歌上看到很多關於它:(我已經將它添加到web.config這種方式:

<add tagPrefix="Scirra" src="~/Controls/Comments.ascx" tagName="Comments"/> 

代碼隱藏頁:

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 

public partial class Controls_Comments : System.Web.UI.UserControl 
{ 
    /// <summary> 
    /// Anchor (GUID/UniqueIdentifier) for the comments 
    /// </summary> 
    public System.Guid Anchor { get; set; } 

    /// <summary> 
    /// Comment page to load 
    /// </summary> 
    public int Page { get; set; } 

    public int TotalComments { get; set; } 
    public int TotalPage { get; set; } 

    protected void Page_Load(object sender, EventArgs e) 
    { 

    } 
} 
+0

什麼是實際的異常消息?例如,編譯器錯誤是什麼意思,或者死亡的黃色屏幕說什麼? – Tejs 2011-04-15 20:26:41

+0

@Tejs我已經更新了黃色屏幕上的所有內容的錯誤 – 2011-04-15 20:28:11

+0

聽起來像你的代碼背後的東西。 – Tejs 2011-04-15 20:29:26

回答

5

如果我理解正確的話,你的聲明命名頁面的公共屬性,這是一個整數:

public int Page { get; set; } 

然後你使用這個屬性應用樣式表皮膚:

@__ctrl.ApplyStyleSheetSkin(this.Page); 

嘗試將您的屬性重命名爲某物其他(PageCount,NumberOfItemsOnPage,PageID等)。 或分配正確的類型此屬性:

public System.Web.UI.Page Page { get; set; } 
0

也有這個奇怪的問題,它讓我拉我的頭髮。然後,我打我....

1)我已經開始了新的VS 2010的C#Web項目

2)我刪除了一堆自動生成的項目文件(包括的Site.Master的)

3)我開始建立我的基本代碼框架

4)我創建了一個新的Site.Master文件

5)當我添加的第一個服務器控件(標籤)的網站。主人,我開始得到錯誤

6.)然後它打我,也許有東西卡在臨時文件,設計器文件或緩存中,它仍然在嘗試編譯(稱之爲)幽靈(缺乏更好的術語)原始網站。主文件沒有添加新的Label控件。

我將我的新Site.Master文件重命名爲SiteMaster.Master,並且該站點再次正常運行。 (很顯然,我必須更新我的所有子頁面以使用新的正確母版頁)。

不確定原始Site.Master ghost文件被隱藏的位置。即使嘗試從C:\,重建項目,清理項目,重新啓動VS,重新啓動PC等等殺死所有臨時ASP.NET文件。超級怪異。

但我只是想我會分享這個愚蠢的錯誤,我跑了20分鐘,然後纔想出來!

最好!