473,396 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

accessing controls in nested master pages

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">
<div runat="server" id="divStep1" class="stepIndex">Step 1<br /
>Eligibility</div>
<div runat="server" id="divStep2" class="stepIndex">Step 2<br /
>Your details<br /><asp:HyperLink ID="ancPersonal"
runat="server"><asp:Image ID="imgHelpPersonal" runat="server" /></
asp:HyperLink></div>
<div runat="server" id="divStep3" class="stepIndex">Step 3<br /
>Travel Info<br /><asp:HyperLink ID="ancTravel"
runat="server"><asp:Image ID="imgHelpTravel" runat="server" /></
asp:HyperLink></div>
<div runat="server" id="divStep4" class="stepIndex">Step 4<br /
>Employer<br /><asp:HyperLink ID="ancEmp" runat="server"><asp:Image
ID="imgHelpEmp" runat="server" /></asp:HyperLink></div>
<div runat="server" id="divStep5" class="stepIndex">Step 5<br /
>Summary</div>
<div runat="server" id="divStep6" class="stepIndex">Step 6<br /
>Complete</div>
</asp:Panel>
<asp:contentplaceholder id="ContentPlaceHolderRegister"
runat="server">
</asp:contentplaceholder>

</asp:Content>

May 1 '07 #1
3 4077
Exactly what do you mean by 'it doesn't work?
Also - does the div have an ID?

David Wier
MVP/AsPInsider
http://aspnet101.com
http://iwritepro.com

"vespaboy" <da*********@gmail.comwrote in message
news:11**********************@n59g2000hsh.googlegr oups.com...
>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">
<div runat="server" id="divStep1" class="stepIndex">Step 1<br /
>>Eligibility</div>
<div runat="server" id="divStep2" class="stepIndex">Step 2<br /
>>Your details<br /><asp:HyperLink ID="ancPersonal"
runat="server"><asp:Image ID="imgHelpPersonal" runat="server" /></
asp:HyperLink></div>
<div runat="server" id="divStep3" class="stepIndex">Step 3<br /
>>Travel Info<br /><asp:HyperLink ID="ancTravel"
runat="server"><asp:Image ID="imgHelpTravel" runat="server" /></
asp:HyperLink></div>
<div runat="server" id="divStep4" class="stepIndex">Step 4<br /
>>Employer<br /><asp:HyperLink ID="ancEmp" runat="server"><asp:Image
ID="imgHelpEmp" runat="server" /></asp:HyperLink></div>
<div runat="server" id="divStep5" class="stepIndex">Step 5<br /
>>Summary</div>
<div runat="server" id="divStep6" class="stepIndex">Step 6<br /
>>Complete</div>
</asp:Panel>
<asp:contentplaceholder id="ContentPlaceHolderRegister"
runat="server">
</asp:contentplaceholder>

</asp:Content>

May 1 '07 #2
On 1 May, 19:53, "David Wier" <d...@nospam.comwrote:
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

"vespaboy" <danielev...@gmail.comwrote in message

news:11**********************@n59g2000hsh.googlegr oups.com...
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">
<div runat="server" id="divStep1" class="stepIndex">Step 1<br /
>Eligibility</div>
<div runat="server" id="divStep2" class="stepIndex">Step 2<br /
>Your details<br /><asp:HyperLink ID="ancPersonal"
runat="server"><asp:Image ID="imgHelpPersonal" runat="server" /></
asp:HyperLink></div>
<div runat="server" id="divStep3" class="stepIndex">Step 3<br /
>Travel Info<br /><asp:HyperLink ID="ancTravel"
runat="server"><asp:Image ID="imgHelpTravel" runat="server" /></
asp:HyperLink></div>
<div runat="server" id="divStep4" class="stepIndex">Step 4<br /
>Employer<br /><asp:HyperLink ID="ancEmp" runat="server"><asp:Image
ID="imgHelpEmp" runat="server" /></asp:HyperLink></div>
<div runat="server" id="divStep5" class="stepIndex">Step 5<br /
>Summary</div>
<div runat="server" id="divStep6" class="stepIndex">Step 6<br /
>Complete</div>
</asp:Panel>
<asp:contentplaceholder id="ContentPlaceHolderRegister"
runat="server">
</asp:contentplaceholder>
</asp:Content>
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">

May 1 '07 #3
On May 1, 8:00 pm, vespaboy <danielev...@gmail.comwrote:
On 1 May, 19:53, "David Wier" <d...@nospam.comwrote:
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
"vespaboy" <danielev...@gmail.comwrote in message
news:11**********************@n59g2000hsh.googlegr oups.com...
>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">
<div runat="server" id="divStep1" class="stepIndex">Step 1<br /
>>Eligibility</div>
<div runat="server" id="divStep2" class="stepIndex">Step 2<br /
>>Your details<br /><asp:HyperLink ID="ancPersonal"
runat="server"><asp:Image ID="imgHelpPersonal" runat="server" /></
asp:HyperLink></div>
<div runat="server" id="divStep3" class="stepIndex">Step 3<br /
>>Travel Info<br /><asp:HyperLink ID="ancTravel"
runat="server"><asp:Image ID="imgHelpTravel" runat="server" /></
asp:HyperLink></div>
<div runat="server" id="divStep4" class="stepIndex">Step 4<br /
>>Employer<br /><asp:HyperLink ID="ancEmp" runat="server"><asp:Image
ID="imgHelpEmp" runat="server" /></asp:HyperLink></div>
<div runat="server" id="divStep5" class="stepIndex">Step 5<br /
>>Summary</div>
<div runat="server" id="divStep6" class="stepIndex">Step 6<br /
>>Complete</div>
</asp:Panel>
<asp:contentplaceholder id="ContentPlaceHolderRegister"
runat="server">
</asp:contentplaceholder>
</asp:Content>

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("ContentPlaceHolde r1").FindControl("divStep1"),
HtmlGenericControl)

May 1 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Steve Franks | last post by:
I have this cool nested master page scenario working great. However what is the correct way to be able to access a strongly typed property at the top level master from a content page that has a...
0
by: Geoff Sullivan | last post by:
Are controls inside a nested master accessible? I have a master (b) which references another master (A). In master (b) I has several ASP controls. On the Page_Load of master (b), I can't seem to...
1
by: Diane Yocom | last post by:
I have two nested master pages, each with public properties. From my content page, I am able to access properties from both pages using either Master.PropertyName (for the child master page) or...
1
by: Rob R. Ainscough | last post by:
I'm running into a problem with Master Pages. I have some "absolute" controls (labels, textboxes) that I position on the page using: ControlObject.Style.Add("Top", "250") or ...
6
by: Steve | last post by:
I'm trying to iterate over all the form controls in my MasterPages content page. Basically, I've got dropdowns, textboxes, etc that I want to format in Page_Load() I've added this code to my...
4
by: jmacduff | last post by:
I have a set of pages ( about 10 ) that all have the same controls at the top, however I am unable to put the controls the master page for the site since the other 50 pages dont have the controls....
4
by: TS | last post by:
Steven, i lost this message conversation from outlook express and made a post online (see last one on this page). Please answer it as it hasn't been yet. thanks The clientID of our controls...
1
by: daveh551 | last post by:
Okay, another problem I'm having with nested master pages on VS 2005. I've got a MasterPage,master, as SubMaster.master, and a DesignTime.master, and a content page, default.aspx. The...
5
by: =?Utf-8?B?bXVzb3NkZXY=?= | last post by:
Hi guys I'm trying to make my code as streamlined as possible, and add CSS file references dynamically when they are required, for example, if a page contains a webcontrol, then the related CSS...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.