我有一个 aspx 文件Report.aspx
<%@ Register Src="~/ReportControls/AverageCostUtilization/AverageCostUtilizationSummaryReport.ascx" TagName="AverageCostUtilizationSummary" TagPrefix="CustomReportControls"%>
<div id="divAverageCostUtilizationDetailed" runat="server" class="row d-flex justify-content-center" style="border:1px solid #00AEC0; width:114%; margin:10px; border-radius:23px;">
<CustomReportControls:AverageCostUtilizationDetailed Id="rprtAverageCostUtilizationDetailed" runat="server"/>
</div>
子班是AverageCostUtilizationDetailed.ascx
<table>
<td Id="InpatientAvgUtilizationPlan1"></td>
</table>
现在,当 TheReport.aspx被加载时
public partial class CompareReports : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(condition)
{
InpatientAvgUtilizationPlan1.innerHtml = "First Condition";
}
else
{
InpatientAvgUtilizationPlan1.innerHtml = "Second Condition";
}
}
}
但是在将值分配到这些表中时出现编译器错误。错误是
The name 'InpatientAvgUtilizationPlan1' dose not exist in the correct context
如何从其父类设置子类的此值
子类的 ascx.cs 代码是
public partial class AverageCostUtilizationSummaryReport : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
}