我的用户控件只显示第一个ascx但是当我导航到其他ascx时,内容没有显示我做错了什么?!
这个想法是在我的aspx页面上我在树形视图的每个节点的左侧TreeView上我想加载一个不同的ascx,它只会改变页面的右侧。
ASPX:
<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Masters/InternalReports.Master" CodeBehind="Reports.aspx.vb" Inherits="DispatchSoftware.Reports" %>
<%@ Register TagPrefix="ReportsPrefix" TagName="rptReports" Src="~/Controls/Reports/rptReport.ascx" %>
<%@ Register TagPrefix="ReportsPrefixTmeOfDay" TagName="rptTimeOfDay" Src="~/Controls/Reports/rptTimeOfDay.ascx" %>
<%@ Register TagPrefix="ReportsPrefixTrending" TagName="rptTrending" Src="~/Controls/Reports/rptTrending.ascx" %>
<%@ Register TagPrefix="ReportsPrefixTopSevenIncidents" TagName="rptTopSevenIncidents" Src="~/Controls/Reports/rptTopSevenIncidents.ascx" %>
<%@ Register TagPrefix="ReportsPrefixTimeCategoriesComparison" TagName="rptTimeCategoriesComparison" Src="~/Controls/Reports/rptTimeCategoriesComparison.ascx" %>
<%@ Register TagPrefix="ReportsPrefixIncidentPerCategory" TagName="rptIncidentPerCategory" Src="~/Controls/Reports/rptIncidentPerCategory.ascx" %>
<%@ Register TagPrefix="ReportsPrefixMaps" TagName="rptMaps" Src="~/Controls/Reports/rptMaps.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="LeftContent" runat="server">
<div id="leftCol">
<div class="elementHeader">
<span class="text">
<asp:Label ID="lblFilter" runat="server" Text="Filter"></asp:Label>
</span>
</div>
<div id="filterWrapperDiv" runat="server" clientidmode="Static">
<telerik:RadPanelBar runat="server" ID="rpbMainMenu" Width="248px" Height="517px" ExpandMode="FullExpandedItem">
<Items>
<telerik:RadPanelItem ImageUrl="~/Images/Layout/Reports.png" Expanded="true" Text="Reports">
<ContentTemplate>
<div style="border: 0px solid red; height: 400px; padding: 10px 10px 10px 10px; overflow: auto;">
<telerik:RadTreeView runat="Server" ID="rtvReports" EnableDragAndDrop="false" Height="300px">
<Nodes>
<telerik:RadTreeNode Text="Statistical Report" Value="StatisticalReport" Expanded="true" CssClass="GeneralFontShape">
<Nodes>
<telerik:RadTreeNode Text="Time of Day" Value="TimeofDay" >
</telerik:RadTreeNode>
<telerik:RadTreeNode Text="Trending" Value="Trending">
</telerik:RadTreeNode>
<telerik:RadTreeNode Text="Top 7 Incidents" Value="Top7Incidents">
</telerik:RadTreeNode>
<telerik:RadTreeNode Text="Incidents Per Category" Value="IncidentsPerCategory">
</telerik:RadTreeNode>
</Nodes>
</telerik:RadTreeNode>
<telerik:RadTreeNode Text="Incident Comparisons" Value="IncidentComparisons" Expanded="true" CssClass="GeneralFontShape">
<Nodes>
<telerik:RadTreeNode Text="Incident Loss" Value="IncidentLoss">
</telerik:RadTreeNode>
</Nodes>
</telerik:RadTreeNode>
<telerik:RadTreeNode Text="Geographic Locations" Value="GeographicLocations" Expanded="true" CssClass="GeneralFontShape">
<Nodes>
<telerik:RadTreeNode Text="Maps" Value="Maps">
</telerik:RadTreeNode>
</Nodes>
</telerik:RadTreeNode>
</Nodes>
</telerik:RadTreeView>
</div>
</ContentTemplate>
</telerik:RadPanelItem>
</Items>
</telerik:RadPanelBar>
</div>
<div class="elementFooter"></div>
</div>
</asp:Content>
<%--Right Handside--%>
<asp:Content ID="Content2" ContentPlaceHolderID="RightContent" runat="server">
<ReportsPrefix:rptReports ID="ucReports" runat="server" Visible="True" />
<ReportsPrefixTmeOfDay:rptTimeOfDay ID="ucTimeOfDay" runat="server" Visible="False" />
<ReportsPrefixTrending:rptTrending ID="ucTrending" runat="server" Visible="False" />
<ReportsPrefixTopSevenIncidents:rptTopSevenIncidents ID="ucTopSevenIncidents" runat="server" Visible="False" />
<ReportsPrefixTimeCategoriesComparison:rptTimeCategoriesComparison ID="ucTimeCategoriesComparison" runat="server" Visible="False" />
<ReportsPrefixIncidentPerCategory:rptIncidentPerCategory ID="ucIncidentPerCategory" runat="server" Visible="False" />
<ReportsPrefixMaps:rptMaps ID="ucMaps" runat="server" Visible="False" />
</asp:Content>
VB代码:
Imports Telerik.Web.UI
Imports System.Drawing
Public Class Reports
Inherits System.Web.UI.Page
Private m_User As UserInfo = Nothing
Private m_SessionID As String
Private m_qrptTOD As String
Private m_qrptTRN As String
Private m_qrptTOS As String
Private m_qrptIPC As String
Private m_qrptCIL As String
Private m_qrptGEO As String
Private Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
m_User = New UserInfo()
If m_User.UserID = 0 Then
Response.Redirect(Globals.gRootRelativeSecureURL("/QuickLogOut.aspx?SessionID=" + m_User.SessionID + "&qCC=" & m_User.CompanyCode))
End If
End Sub
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")
m_qrptTRN = Request.QueryString("qrptTRN")
m_qrptTOS = Request.QueryString("qrptTOS")
m_qrptIPC = Request.QueryString("qrptIPC")
m_qrptCIL = Request.QueryString("qrptCIL")
m_qrptGEO = Request.QueryString("qrptGEO")
ElseIf Not String.IsNullOrEmpty(Session("SessionID")) Then
m_SessionID = Session("SessionID")
End If
If m_qrptTOD = "tod" Then
'=== Clearing the right hand side and loading the new ascx.
Me.Master.FindControl("RightContent").Controls.Clear()
Me.Master.FindControl("RightContent").Controls.Add(Page.LoadControl(("/Controls/Reports/rptTimeOfDay.ascx")))
End If
If m_qrptTRN = "trn" Then
Me.Master.FindControl("RightContent").Controls.Clear()
Me.Master.FindControl("RightContent").Controls.Add(Page.LoadControl(("/Controls/Reports/rptTrending.ascx")))
End If
If m_qrptTOS = "tos" Then
Me.Master.FindControl("RightContent").Controls.Clear()
Me.Master.FindControl("RightContent").Controls.Add(Page.LoadControl(("/Controls/Reports/rptTopSevenIncidents.ascx")))
End If
If m_qrptIPC = "ipc" Then
Me.Master.FindControl("RightContent").Controls.Clear()
Me.Master.FindControl("RightContent").Controls.Add(Page.LoadControl(("/Controls/Reports/rptIncidentPerCategory.ascx")))
End If
If m_qrptCIL = "cil" Then
Me.Master.FindControl("RightContent").Controls.Clear()
Me.Master.FindControl("RightContent").Controls.Add(Page.LoadControl(("/Controls/Reports/rptTimeCategoriesComparison.ascx")))
End If
If m_qrptGEO = "geo" Then
Me.Master.FindControl("RightContent").Controls.Clear()
Me.Master.FindControl("RightContent").Controls.Add(Page.LoadControl(("/Controls/Reports/rptMaps.ascx")))
End If
Catch ex As Exception
End Try
End Sub
Protected Sub GenerateDataSets()
Try
Catch ex As Exception
End Try
End Sub
Protected Sub GenerateLabels()
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("Trending")
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")
statTrendsNode.NavigateUrl = Globals.gRootRelativeSecureURL("/Reports/Reports.aspx?SessionID=" + m_SessionID + "&qrptTRN=trn")
statTopSevenIncidents.NavigateUrl = Globals.gRootRelativeSecureURL("/Reports/Reports.aspx?SessionID=" + m_SessionID + "&qrptTOS=tos")
statIncidentPerCategory.NavigateUrl = Globals.gRootRelativeSecureURL("/Reports/Reports.aspx?SessionID=" + m_SessionID + "&qrptIPC=ipc")
compIncidentLoss.NavigateUrl = Globals.gRootRelativeSecureURL("/Reports/Reports.aspx?SessionID=" + m_SessionID + "&qrptCIL=cil")
GeoMaps.NavigateUrl = Globals.gRootRelativeSecureURL("/Reports/Reports.aspx?SessionID=" + m_SessionID + "&qrptGEO=geo")
End Sub
Protected Sub GenerateControls()
End Sub
Protected Sub GenerateOther()
End Sub
End Class