したがって、私がやりたいのは、ドロップダウンの選択に基づいてロードするユーザーコントロールを見つけることだけです。ユーザーコントロールを追加しましたが、コントロールを見つけようとしているので、そこからいくつかのプロパティにアクセスでき、一生コントロールを見つけることができません。私は実際にこれらすべてをマスターページで行っており、default.aspxページ自体にはコードがありません。どんな助けでもいただければ幸いです。
MasterPage.aspx
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager runat="server">
</asp:ScriptManager>
</div>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false"
OnLoad="UpdatePanel2_Load">
<ContentTemplate>
<div class="toolbar">
<div class="section">
<asp:DropDownList ID="ddlDesiredPage" runat="server" AutoPostBack="True" EnableViewState="True"
OnSelectedIndexChanged="goToSelectedPage">
</asp:DropDownList>
<asp:DropDownList ID="ddlDesiredPageSP" runat="server" AutoPostBack="True" EnableViewState="True" OnSelectedIndexChanged="goToSelectedPage">
</asp:DropDownList>
<br />
<span class="toolbarText">Select a Page to Edit</span>
</div>
<div class="options">
<div class="toolbarButton">
<asp:LinkButton ID="lnkSave" CssClass="modal" runat="server" OnClick="lnkSave_Click"><span class="icon" id="saveIcon" title="Save"></span>Save</asp:LinkButton>
</div>
</div>
</div>
</ContentTemplate>
<Triggers>
</Triggers>
</asp:UpdatePanel>
<div id="contentContainer">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" OnLoad="UpdatePanel1_Load" UpdateMode="Conditional"
ChildrenAsTriggers="False">
<ContentTemplate>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="lnkHome" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="rdoTemplate" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</div>
MasterPage.cs
protected void goToSelectedPage(object sender, System.EventArgs e)
{
temp1 ct = this.Page.Master.LoadControl("temp1.ascx") as temp1;
ct.ID = "TestMe";
this.UpdatePanel1.ContentTemplateContainer.Controls.Add(ct);
}
//This is where I CANNOT SEEM TO FIND THE CONTROL ////////////////////////////////////////
protected void lnkSave_Click(object sender, System.EventArgs e)
{
UpdatePanel teest = this.FindControl("UpdatePanel1") as UpdatePanel;
Control test2 = teest.ContentTemplateContainer.FindControl("ctl09") as Control;
temp1 test3 = test2.FindControl("TestMe") as temp1;
string maybe = test3.Col1TopTitle;
}
ここで私はそれが私に何を言っているのか理解していません。「par」の場合、「ctl09」を取得しますが、このコントロールをどのように見つける必要があるのかわかりません。temp1.ascx.cs
protected void Page_Load(object sender, EventArgs e)
{
string ppp = this.ID;
string par = this.Parent.ID;
}