我正在尝试设置导航栏中的标签文本。此导航栏在我的母版页中,我正在使用Master.nameoflabel尝试在我的内容页中设置标签的文本。但是,当我尝试设置文本时,会得到一个空引用异常,因为我的标签未返回任何无法弄清的内容。这些是我尝试在内容页面中设置的标签:
<div class="leftPanel">
<%-- DXCOMMENT: Configure the left panel's ASPxNavBar --%>
<dx:ASPxNavBar ID="ASPxNavBar1" runat="server" AutoCollapse="false" EnableAnimation="True" Theme="Default">
<ItemStyle Wrap="True"></ItemStyle>
<Border BorderWidth="0px" />
<Paddings Padding="0px" />
<Groups>
<dx:NavBarGroup Text="Totals" Expanded="True">
<Items>
<dx:NavBarItem>
<Template>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Always">
<ContentTemplate>
<dx:ASPxLabel ID="potentialDeadStocklbl" runat="server" Text="test123"></dx:ASPxLabel>
<dx:ASPxLabel ID="potentialMTLDeadStocklbl" runat="server" Text="test"></dx:ASPxLabel>
<dx:ASPxLabel ID="potentialWIPDeadStocklbl" runat="server" Text="test"></dx:ASPxLabel>
<dx:ASPxLabel ID="toolingDeadStocklbl" runat="server" Text="test"></dx:ASPxLabel>
<dx:ASPxLabel ID="estimatedDeadStockTotallbl" runat="server" Text="test"></dx:ASPxLabel>
</ContentTemplate>
</asp:UpdatePanel>
</Template>
</dx:NavBarItem>
</Items>
</dx:NavBarGroup>
</Groups>
</dx:ASPxNavBar>
</div>
在此母版页的代码后面,我正在如下属性中设置文本:
Public Property FGDeadStock As String
Get
Return potentialDeadStocklbl.Text
End Get
Set(value As String)
potentialDeadStocklbl.Text = value
End Set
End Property
Public Property MTLDeadStock As String
Get
Return potentialMTLDeadStocklbl.Text
End Get
Set(value As String)
potentialMTLDeadStocklbl.Text = value
End Set
End Property
Public Property WIPDeadStock As String
Get
Return potentialWIPDeadStocklbl.Text
End Get
Set(value As String)
potentialWIPDeadStocklbl.Text = value
End Set
End Property
Public Property ToolingDeadStock As String
Get
Return toolingDeadStocklbl.Text
End Get
Set(value As String)
toolingDeadStocklbl.Text = value
End Set
End Property
Public Property EstimatedDeadStockTotal As String
Get
Return estimatedDeadStockTotallbl.Text
End Get
Set(value As String)
estimatedDeadStockTotallbl.Text = value
End Set
End Property
然后在我的内容页面中,我试图设置文本:
Master.FGDeadStock = "Test"
Master.MTLDeadStock = "Test1"
Master.WIPDeadStock = "Test2"
Master.ToolingDeadStock = "Test3"
Master.EstimatedDeadStockTotal = "Test4"
我在不同的页面上做了非常相似的事情,但在另一页面上却能正常工作,我不确定为什么这行不通,也许有一些我不注意的小事情,谢谢您。< / p>