Compiler Error Message: CS0122: 'Controls_Arcade_StarDisplay.Stars' is inaccessible due to its protection level
我检查了其他 SO 线程,但无法理解它们。此控件正在另一个 webusercontrol 中使用。每当我尝试用它做任何事情时,它都会抛出这个错误。有问题的课程是这样的:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="StarDisplay.ascx.cs" Inherits="Controls_Arcade_StarDisplay" %>
<asp:Panel runat="server" ID="Stars" />
后面的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Runtime.CompilerServices;
public partial class Controls_Arcade_StarDisplay : System.Web.UI.UserControl
{
public double Rating { get; set; }
public string Tooltip { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
string CSSClass = "star-rating s-";
if (Rating < 0.25)
CSSClass += "0";
else if (Rating < 0.75)
CSSClass += "05";
else if (Rating < 1.25)
CSSClass += "1";
else if (Rating < 1.75)
CSSClass += "15";
else if (Rating < 2.25)
CSSClass += "2";
else if (Rating < 2.75)
CSSClass += "25";
else if (Rating < 3.25)
CSSClass += "3";
else if (Rating < 3.75)
CSSClass += "35";
else if (Rating < 4.25)
CSSClass += "4";
else if (Rating < 4.75)
CSSClass += "4";
else if (Rating < 1.25)
CSSClass += "1";
else if (Rating < 4.75)
CSSClass += "45";
else
CSSClass += "5";
Stars.CssClass = CSSClass;
if (Tooltip != null)
Stars.ToolTip = Tooltip;
}
}
该控件在 web.config 中注册:
<pages validateRequest="false" smartNavigation="false" clientIDMode="Static">
<controls>
<add tagPrefix="Scirra" src="~/Controls/Arcade/GameOverview.ascx" tagName="GameOverview"/>
<add tagPrefix="Scirra" src="~/Controls/Arcade/Stars/StarDisplay.ascx" tagName="StarDisplay"/>
</controls>
</pages>
开始显示控件出现在游戏概览控件中。
感谢您的帮助,完全卡住了!其他问题涉及获取我不理解的控件的属性,或者更改我也找不到的设计器中的内容。