S
Scott
I'm using a master page (mp_TableMaint.aspx) with one Content area (ID:
Content1). Content1 contains several usercontrols, which are hidden. The
goal is to show the correct control based on the querystring passed when
calling mp_TableMaint (the page is called from an ASP.NET 2.0 Menu control
on my index.aspx page). I believe I understand correctly that the Master
Page's ASP Content control (named Content1) is, itself, a server side
control. My problem is determining how to show/hide my other user controls
based on user selection. I'm using VB, and have tried every one of the page
events to determine when the controls are populated into Content1, but
obviously I'm doing something wrong.
I've tried this:
Me.Controls(0).ID
which results in a control named "ct001" or something
Also tried:
Me.Controls(0).Controls.Count
This gives me a count of 5, which is correct, but if I do this:
Me.Controls(0).Controls(1).ID (or any other number instead of 1)
in the Immediate window VS returns "Nothing"
I've also tried using FindControl to locate the control.
Is this the best way to achieve this? All I need to do is show/hide a
usercontrol on my Content page based on the querystring value passed in.
I'm using Visual Studio 2005 if it makes a difference.
I don't know if this helps, but here's the source from the table:
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master"
AutoEventWireup="false"
CodeFile="mp_TableMaint.aspx.vb" Inherits="webPilotLogbook.mp_TableMaint"
Title="Tables" %>
<%@ Register Src="WebControls/ratings.ascx" TagName="ratings"
TagPrefix="uc8" %>
<%@ Register Src="WebControls/powercharacteristics.ascx"
TagName="powercharacteristics"
TagPrefix="uc7" %>
<%@ Register Src="WebControls/aircraftcategory.ascx"
TagName="aircraftcategory" TagPrefix="uc1" %>
<%@ Register Src="WebControls/aircraftclass.ascx" TagName="aircraftclass"
TagPrefix="uc2" %>
<%@ Register Src="WebControls/aircraftclassification.ascx"
TagName="aircraftclassification"
TagPrefix="uc3" %>
<%@ Register Src="WebControls/aircraftid2.ascx" TagName="aircraftid2"
TagPrefix="uc4" %>
<%@ Register Src="WebControls/make.ascx" TagName="make" TagPrefix="uc5" %>
<%@ Register Src="WebControls/certificates.ascx" TagName="certificates"
TagPrefix="uc6" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
runat="Server">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
</td>
<td>
<table align="center">
<tr>
<td align="center">
<%-- <uc1:AircraftCategory id="AircraftCategory1" runat="server"
Visible="False" />
<uc1:AircraftClass id="AircraftClass1" runat="server"
Visible="False"></uc1:AircraftClass>
<uc1:AircraftClassification id="AircraftClassification1" runat="server"
Visible="False"></uc1:AircraftClassification>
<uc1:Certificates id="Certificates1" runat="server"
Visible="False"></uc1:Certificates>
<uc1:Make1 id="Make1" runat="server" Visible="False"></uc1:Make1>
<uc1owerCharacteristics id="PowerCharacteristics1" runat="server"
Visible="False"></uc1owerCharacteristics>
<uc1:Ratings id="Ratings1" runat="server" Visible="False"></uc1:Ratings>
<uc1:AircraftId2 id="AircraftId21" runat="server"
Visible="False"></uc1:AircraftId2>
--%>
<uc1:aircraftcategory ID="Aircraftcategory1" runat="server" />
<uc7owercharacteristics ID="Powercharacteristics1" runat="server" />
<uc8:ratings ID="Ratings1" runat="server" />
<uc6:certificates ID="Certificates1" runat="server" />
<uc5:make ID="Make1" runat="server" />
<uc4:aircraftid2 ID="Aircraftid2_1" runat="server" />
<uc3:aircraftclassification ID="Aircraftclassification1" runat="server" />
<uc2:aircraftclass ID="Aircraftclass1" runat="server" />
</td>
</tr>
</table>
</td>
<td>
</td>
</tr>
</table>
</asp:Content>
Content1). Content1 contains several usercontrols, which are hidden. The
goal is to show the correct control based on the querystring passed when
calling mp_TableMaint (the page is called from an ASP.NET 2.0 Menu control
on my index.aspx page). I believe I understand correctly that the Master
Page's ASP Content control (named Content1) is, itself, a server side
control. My problem is determining how to show/hide my other user controls
based on user selection. I'm using VB, and have tried every one of the page
events to determine when the controls are populated into Content1, but
obviously I'm doing something wrong.
I've tried this:
Me.Controls(0).ID
which results in a control named "ct001" or something
Also tried:
Me.Controls(0).Controls.Count
This gives me a count of 5, which is correct, but if I do this:
Me.Controls(0).Controls(1).ID (or any other number instead of 1)
in the Immediate window VS returns "Nothing"
I've also tried using FindControl to locate the control.
Is this the best way to achieve this? All I need to do is show/hide a
usercontrol on my Content page based on the querystring value passed in.
I'm using Visual Studio 2005 if it makes a difference.
I don't know if this helps, but here's the source from the table:
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master"
AutoEventWireup="false"
CodeFile="mp_TableMaint.aspx.vb" Inherits="webPilotLogbook.mp_TableMaint"
Title="Tables" %>
<%@ Register Src="WebControls/ratings.ascx" TagName="ratings"
TagPrefix="uc8" %>
<%@ Register Src="WebControls/powercharacteristics.ascx"
TagName="powercharacteristics"
TagPrefix="uc7" %>
<%@ Register Src="WebControls/aircraftcategory.ascx"
TagName="aircraftcategory" TagPrefix="uc1" %>
<%@ Register Src="WebControls/aircraftclass.ascx" TagName="aircraftclass"
TagPrefix="uc2" %>
<%@ Register Src="WebControls/aircraftclassification.ascx"
TagName="aircraftclassification"
TagPrefix="uc3" %>
<%@ Register Src="WebControls/aircraftid2.ascx" TagName="aircraftid2"
TagPrefix="uc4" %>
<%@ Register Src="WebControls/make.ascx" TagName="make" TagPrefix="uc5" %>
<%@ Register Src="WebControls/certificates.ascx" TagName="certificates"
TagPrefix="uc6" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
runat="Server">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
</td>
<td>
<table align="center">
<tr>
<td align="center">
<%-- <uc1:AircraftCategory id="AircraftCategory1" runat="server"
Visible="False" />
<uc1:AircraftClass id="AircraftClass1" runat="server"
Visible="False"></uc1:AircraftClass>
<uc1:AircraftClassification id="AircraftClassification1" runat="server"
Visible="False"></uc1:AircraftClassification>
<uc1:Certificates id="Certificates1" runat="server"
Visible="False"></uc1:Certificates>
<uc1:Make1 id="Make1" runat="server" Visible="False"></uc1:Make1>
<uc1owerCharacteristics id="PowerCharacteristics1" runat="server"
Visible="False"></uc1owerCharacteristics>
<uc1:Ratings id="Ratings1" runat="server" Visible="False"></uc1:Ratings>
<uc1:AircraftId2 id="AircraftId21" runat="server"
Visible="False"></uc1:AircraftId2>
--%>
<uc1:aircraftcategory ID="Aircraftcategory1" runat="server" />
<uc7owercharacteristics ID="Powercharacteristics1" runat="server" />
<uc8:ratings ID="Ratings1" runat="server" />
<uc6:certificates ID="Certificates1" runat="server" />
<uc5:make ID="Make1" runat="server" />
<uc4:aircraftid2 ID="Aircraftid2_1" runat="server" />
<uc3:aircraftclassification ID="Aircraftclassification1" runat="server" />
<uc2:aircraftclass ID="Aircraftclass1" runat="server" />
</td>
</tr>
</table>
</td>
<td>
</td>
</tr>
</table>
</asp:Content>