无法将控件添加到usercontrol

Tom*_*len 1 c# asp.net user-controls

这有效:

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

Add comment
Run Code Online (Sandbox Code Playgroud)

但是这个:

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

Add comment
<asp:Button runat="server" ID="lol" />
Run Code Online (Sandbox Code Playgroud)

抛出我以前从未见过的错误:

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 
Run Code Online (Sandbox Code Playgroud)

任何帮助赞赏,我在谷歌上看不到很多关于它:(我已经将它添加到web.config这样:

<add tagPrefix="Scirra" src="~/Controls/Comments.ascx" tagName="Comments"/>
Run Code Online (Sandbox Code Playgroud)

页面代码背后:

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)
    {

    }
}
Run Code Online (Sandbox Code Playgroud)

Jac*_*cco 6

如果我理解正确,你声明一个名为Page的公共属性,它是一个整数:

public int Page { get; set; }
Run Code Online (Sandbox Code Playgroud)

然后使用此属性应用样式表皮肤:

@__ctrl.ApplyStyleSheetSkin(this.Page);
Run Code Online (Sandbox Code Playgroud)

尝试将您的属性重命名为其他内容(PageCount,NumberOfItemsOnPage,PageID等).或者为此属性指定正确的类型:

public System.Web.UI.Page Page { get; set; }
Run Code Online (Sandbox Code Playgroud)