aspx页面布局如下
<asp:Content ID="PageContent" ContentPlaceHolderID="PageContent" runat="Server">
<div id="checkout_onePage" class="mainContentWrapper opcOverlayWrapper">
<script language="javascript" type="text/javascript">
Page_ClientValidate();
</script>
<div id="PageOverlay" runat="server" visible="false" class="opcOverlay"></div>
<ajax:Accordion ID="UserAccordion" runat="server" SelectedIndex="0" HeaderCssClass="accordionHeader"
HeaderSelectedCssClass="accordionHeaderSelected" ContentCssClass="accordionContent" FadeTransitions="true" SuppressHeaderPostbacks="true" TransitionDuration="250" FramesPerSecond="40" RequireOpenedPane="true" AutoSize="None">
<Panes>
<ajax:AccordionPane ID="BillingInformation" runat="server">
<Header>
<div id="billingAddr" class="widget billingAddressWidget aboveOpcOverlay">
<div class="header">
<h2>Billing Information</h2>
</div>
</div>
</Header>
<Content>
<div class="aboveOpcOverlay">
<asp:UpdatePanel ID="UPBilling" runat="server">
<ContentTemplate>
<div class="content floatleft">
<asp:PlaceHolder ID="LoginPanel" runat="server" EnableViewState="False" Visible="false">
<p class="LoginMessage">
If you have previously created an account, you can
<asp:HyperLink ID="LoginLink" runat="server" Text="log in" EnableViewState="false" CssClass="button"></asp:HyperLink>
to retrieve your saved addresses.
</p>
</asp:PlaceHolder>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</Content>
</ajax:AccordionPane>
<ajax:AccordionPane ID="ShippingInformation" runat="server">
<Header>
<div class="widget shippingAddressWidget aboveOpcOverlay">
<div class="header">
<h2>Shipping Information</h2>
</div>
</div>
</Header>
<Content>
<asp:Panel ID="ShippingAddressPanel" runat="server" Visible="true">
<div class="aboveOpcOverlay">
<div class="content" runat="server" id="Div_Main_Shipping_Information">
</div>
</div>
<table>
<tr id="trShippingAddress" runat="server" visible="false">
<td>
<uc2:AddressDetails ID="ShippingAddress" runat="server" ValidationGroupName="Shipping" />
</td>
</tr>
</table>
</asp:Panel>
</Content>
</ajax:AccordionPane>
</Panes>
</ajax:Accordion>
我在上面的页面中分配了一个用户控件,我无法找到名为Div_Main_Shipping_Information的div控件
我的usercontrol代码如下
Content PageContent = (Content)this.Parent.FindControl("PageContent");
Accordion UserAccordion = (Accordion)PageContent.FindControl("UserAccordion");
AccordionPane shipInfoPane = UserAccordion.Panes["ShippingInformation"];
Panel ShippingAddressPanel = (Panel)shipInfoPane.FindControl("ShippingAddressPanel");
System.Web.UI.HtmlControls.HtmlGenericControl Div_Main_Shipping_Information = (System.Web.UI.HtmlControls.HtmlGenericControl)ShippingAddressPanel.FindControl("Div_Main_Shipping_Information");
但我无法找到我的控制手风琴控制,面板控制或我的div控制。
答案 0 :(得分:0)
using AjaxControlToolkit;
Accordion userAccordion = (Accordion)this.Page.FindControl("UserAccordion");
AccordionPane shipInfoPane = userAccordion.Panes["ShippingInformation"];
Panel ShippingAddressPanel = (Panel)shipInfoPane.FindControl("ShippingAddressPanel");
System.Web.UI.HtmlControls.HtmlGenericControl Div_Main_Shipping_Information = (System.Web.UI.HtmlControls.HtmlGenericControl)ShippingAddressPanel.FindControl("Div_Main_Shipping_Information");