在我的母版页中,我有ContentPlaceHolder用于左侧内容,正确的内容见下文:
<body class="software">
<form id="form1" name="MyFrom" runat="server">
<telerik:RadScriptManager runat="server" ID="RadScriptManager1" ></telerik:RadScriptManager>
<div>
<div id="wrapper">
<menu:main id="mainMenu" runat="server"/>
<div id="leftCol">
<asp:ContentPlaceHolder ID="LeftContent" runat="server">
</asp:ContentPlaceHolder>
</div>
<div id="rightCol">
<asp:ContentPlaceHolder ID="RightContent" runat="server">
</asp:ContentPlaceHolder>
</div>
</div>
</div>
</form>
</body>
在我的aspx页面上,我在TreeView的每个节点的左侧都有TreeView我想加载一个不同的ascx,它只会改变页面的右侧 我想设置可见的false并加载其他ascx问题它给我一个错误:对象引用未设置为对象的实例。
如何以正确的方式访问页面上的ascx ???
Me.Master.FindControl("RightContent").Page.FindControl("/Controls/Reports/rptReport.ascx").Visible = False
这就是我在rptReport.ascx上的内容:
<%--Right Side--%>
<div id="rightCol" >
<div class="elementHeader" id="elementHeader">
<span class="text"><asp:Label ID="lblReports" runat="server" Text="Reports"></asp:Label></span>
</div>
<div id="divRightWrapper" class="rightWrapperDiv" runat="server">
<div>
<img id="imgCaseGlobalReports" runat="server" alt="" src="~/Images/Replacements/IncidentReports.png"/>
</div>
</div>
</div>
我想隐藏并加载不同的ascx
aspx.vb:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
RetrieveAllQueryStringParams()
If Not IsPostBack Then
GenerateDataSets()
GenerateLabels()
GenerateLinks()
GenerateControls()
GenerateOther()
End If
End Sub
Private Sub RetrieveAllQueryStringParams()
Try
If Not String.IsNullOrEmpty(Request.QueryString("SessionID")) Then
m_SessionID = Request.QueryString("SessionID")
m_qrptTOD = Request.QueryString("qrptTOD")
ElseIf Not String.IsNullOrEmpty(Session("SessionID")) Then
m_SessionID = Session("SessionID")
End If
If m_qrptTOD = "tod" Then
Me.Master.FindControl("RightContent").Page.FindControl("/Controls/Reports/rptReport.ascx").Visible = False
Me.Master.FindControl("RightContent").Controls.Add(Page.LoadControl(("/Controls/Reports/rptTimeOfDay.ascx")))
End If
Catch ex As Exception
End Try
End Sub
Protected Sub GenerateLinks()
Dim subTreeStatisticalReport As RadTreeNode = rtvReports.Nodes.FindNodeByValue("StatisticalReport")
Dim subTreeIncidentComparisons As RadTreeNode = rtvReports.Nodes.FindNodeByValue("IncidentComparisons")
Dim subTreeGeographicLocations As RadTreeNode = rtvReports.Nodes.FindNodeByValue("GeographicLocations")
Dim statTimeOfDayNode As RadTreeNode = subTreeStatisticalReport.Nodes.FindNodeByValue("TimeofDay")
Dim statTrendsNode As RadTreeNode = subTreeStatisticalReport.Nodes.FindNodeByValue("Trends")
Dim statTopSevenIncidents As RadTreeNode = subTreeStatisticalReport.Nodes.FindNodeByValue("Top7Incidents")
Dim statIncidentPerCategory As RadTreeNode = subTreeStatisticalReport.Nodes.FindNodeByValue("IncidentsPerCategory")
Dim compIncidentLoss As RadTreeNode = subTreeIncidentComparisons.Nodes.FindNodeByValue("IncidentLoss")
Dim GeoMaps As RadTreeNode = subTreeGeographicLocations.Nodes.FindNodeByValue("Maps")
statTimeOfDayNode.NavigateUrl = Globals.gRootRelativeSecureURL("/Reports/Reports.aspx?SessionID=" + m_SessionID + "&qrptTOD=tod")
End Sub