accessing controls in nested master pages

  • Thread starter Thread starter vespaboy
  • Start date Start date
V

vespaboy

i need to access a <div runat="server"> which sits in a master page
which is itself nested in a master page. i've tried this code but it
doesn't work:

Page:

Dim divStep1 As HtmlGenericControl =
CType(Master.FindControl("divStep1"), HtmlGenericControl)

Master page:

<%@ Master MasterPageFile="~/MasterPage.master" Language="VB"
CodeFile="MasterRegister.master.vb" Inherits="MasterRegister" %>
<asp:Content ID="ContentRegister"
ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<asp:Panel CssClass="pnlStepIndex" ID="pnlStepIndex" runat="server"
Width="450px">
Eligibility</div>
Your details<br /><asp:HyperLink ID="ancPersonal"
runat="server"><asp:Image ID="imgHelpPersonal" runat="server" /></
asp:HyperLink> said:
Travel Info<br /><asp:HyperLink ID="ancTravel"
runat="server"><asp:Image ID="imgHelpTravel" runat="server" /></
asp:HyperLink> said:
Employer<br /><asp:HyperLink ID="ancEmp" runat="server"><asp:Image
ID="imgHelpEmp" runat="server" /> said:
Summary</div>
Complete</div>
</asp:Panel>
<asp:contentplaceholder id="ContentPlaceHolderRegister"
runat="server">
</asp:contentplaceholder>

</asp:Content>
 
Exactly what do you mean by 'it doesn't work?
Also - does the div have an ID?

David Wier
MVP/AsPInsiderhttp://aspnet101.comhttp://iwritepro.com

sorry, error is "Object reference not set to an instance of an object"

the div is in the master page:
<div runat="server" id="divStep1" class="stepIndex">
 
sorry, error is "Object reference not set to an instance of an object"

the div is in the master page:
<div runat="server" id="divStep1" class="stepIndex">

i've worked it out:

Dim divStep1 As HtmlGenericControl =
CType(Master.Master.FindControl("ContentPlaceHolder1").FindControl("divStep1"),
HtmlGenericControl)
 
Back
Top