accessing controls in nested master pages

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>
 
V

vespaboy

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">
 
V

vespaboy

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top