473,657 Members | 2,574 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

accessing controls in nested master pages

i need to access a <div runat="server"w hich 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 HtmlGenericCont rol =
CType(Master.Fi ndControl("divS tep1"), HtmlGenericCont rol)

Master page:

<%@ Master MasterPageFile= "~/MasterPage.mast er" Language="VB"
CodeFile="Maste rRegister.maste r.vb" Inherits="Maste rRegister" %>
<asp:Content ID="ContentRegi ster"
ContentPlaceHol derID="ContentP laceHolder1" Runat="Server">

<asp:Panel CssClass="pnlSt epIndex" ID="pnlStepInde x" runat="server"
Width="450px">
<div runat="server" id="divStep1" class="stepInde x">Step 1<br /
>Eligibility</div>
<div runat="server" id="divStep2" class="stepInde x">Step 2<br /
>Your details<br /><asp:HyperLi nk ID="ancPersonal "
runat="server"> <asp:Image ID="imgHelpPers onal" runat="server" /></
asp:HyperLink></div>
<div runat="server" id="divStep3" class="stepInde x">Step 3<br /
>Travel Info<br /><asp:HyperLi nk ID="ancTravel"
runat="server"> <asp:Image ID="imgHelpTrav el" runat="server" /></
asp:HyperLink></div>
<div runat="server" id="divStep4" class="stepInde x">Step 4<br /
>Employer<br /><asp:HyperLi nk ID="ancEmp" runat="server"> <asp:Image
ID="imgHelpEmp " runat="server" /></asp:HyperLink></div>
<div runat="server" id="divStep5" class="stepInde x">Step 5<br /
>Summary</div>
<div runat="server" id="divStep6" class="stepInde x">Step 6<br /
>Complete</div>
</asp:Panel>
<asp:contentpla ceholder id="ContentPlac eHolderRegister "
runat="server">
</asp:contentplac eholder>

</asp:Content>

May 1 '07 #1
3 4083
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*********@gm ail.comwrote in message
news:11******** **************@ n59g2000hsh.goo glegroups.com.. .
>i need to access a <div runat="server"w hich 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 HtmlGenericCont rol =
CType(Master.Fi ndControl("divS tep1"), HtmlGenericCont rol)

Master page:

<%@ Master MasterPageFile= "~/MasterPage.mast er" Language="VB"
CodeFile="Maste rRegister.maste r.vb" Inherits="Maste rRegister" %>
<asp:Content ID="ContentRegi ster"
ContentPlaceHol derID="ContentP laceHolder1" Runat="Server">

<asp:Panel CssClass="pnlSt epIndex" ID="pnlStepInde x" runat="server"
Width="450px">
<div runat="server" id="divStep1" class="stepInde x">Step 1<br /
>>Eligibility </div>
<div runat="server" id="divStep2" class="stepInde x">Step 2<br /
>>Your details<br /><asp:HyperLi nk ID="ancPersonal "
runat="server"> <asp:Image ID="imgHelpPers onal" runat="server" /></
asp:HyperLink></div>
<div runat="server" id="divStep3" class="stepInde x">Step 3<br /
>>Travel Info<br /><asp:HyperLi nk ID="ancTravel"
runat="server"> <asp:Image ID="imgHelpTrav el" runat="server" /></
asp:HyperLink></div>
<div runat="server" id="divStep4" class="stepInde x">Step 4<br /
>>Employer<br /><asp:HyperLi nk ID="ancEmp" runat="server"> <asp:Image
ID="imgHelpEmp " runat="server" /></asp:HyperLink></div>
<div runat="server" id="divStep5" class="stepInde x">Step 5<br /
>>Summary</div>
<div runat="server" id="divStep6" class="stepInde x">Step 6<br /
>>Complete</div>
</asp:Panel>
<asp:contentpla ceholder id="ContentPlac eHolderRegister "
runat="server">
</asp:contentplac eholder>

</asp:Content>

May 1 '07 #2
On 1 May, 19:53, "David Wier" <d...@nospam.co mwrote:
Exactly what do you mean by 'it doesn't work?
Also - does the div have an ID?

David Wier
MVP/AsPInsiderhttp://aspnet101.comht tp://iwritepro.com

"vespaboy" <danielev...@gm ail.comwrote in message

news:11******** **************@ n59g2000hsh.goo glegroups.com.. .
i need to access a <div runat="server"w hich 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 HtmlGenericCont rol =
CType(Master.Fi ndControl("divS tep1"), HtmlGenericCont rol)
Master page:
<%@ Master MasterPageFile= "~/MasterPage.mast er" Language="VB"
CodeFile="Maste rRegister.maste r.vb" Inherits="Maste rRegister" %>
<asp:Content ID="ContentRegi ster"
ContentPlaceHol derID="ContentP laceHolder1" Runat="Server">
<asp:Panel CssClass="pnlSt epIndex" ID="pnlStepInde x" runat="server"
Width="450px">
<div runat="server" id="divStep1" class="stepInde x">Step 1<br /
>Eligibility</div>
<div runat="server" id="divStep2" class="stepInde x">Step 2<br /
>Your details<br /><asp:HyperLi nk ID="ancPersonal "
runat="server"> <asp:Image ID="imgHelpPers onal" runat="server" /></
asp:HyperLink></div>
<div runat="server" id="divStep3" class="stepInde x">Step 3<br /
>Travel Info<br /><asp:HyperLi nk ID="ancTravel"
runat="server"> <asp:Image ID="imgHelpTrav el" runat="server" /></
asp:HyperLink></div>
<div runat="server" id="divStep4" class="stepInde x">Step 4<br /
>Employer<br /><asp:HyperLi nk ID="ancEmp" runat="server"> <asp:Image
ID="imgHelpEmp " runat="server" /></asp:HyperLink></div>
<div runat="server" id="divStep5" class="stepInde x">Step 5<br /
>Summary</div>
<div runat="server" id="divStep6" class="stepInde x">Step 6<br /
>Complete</div>
</asp:Panel>
<asp:contentpla ceholder id="ContentPlac eHolderRegister "
runat="server">
</asp:contentplac eholder>
</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="stepInde x">

May 1 '07 #3
On May 1, 8:00 pm, vespaboy <danielev...@gm ail.comwrote:
On 1 May, 19:53, "David Wier" <d...@nospam.co mwrote:
Exactly what do you mean by 'it doesn't work?
Also - does the div have an ID?
David Wier
MVP/AsPInsiderhttp://aspnet101.comht tp://iwritepro.com
"vespaboy" <danielev...@gm ail.comwrote in message
news:11******** **************@ n59g2000hsh.goo glegroups.com.. .
>i need to access a <div runat="server"w hich 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 HtmlGenericCont rol =
CType(Master.Fi ndControl("divS tep1"), HtmlGenericCont rol)
Master page:
<%@ Master MasterPageFile= "~/MasterPage.mast er" Language="VB"
CodeFile="Maste rRegister.maste r.vb" Inherits="Maste rRegister" %>
<asp:Content ID="ContentRegi ster"
ContentPlaceHol derID="ContentP laceHolder1" Runat="Server">
<asp:Panel CssClass="pnlSt epIndex" ID="pnlStepInde x" runat="server"
Width="450px">
<div runat="server" id="divStep1" class="stepInde x">Step 1<br /
>>Eligibility </div>
<div runat="server" id="divStep2" class="stepInde x">Step 2<br /
>>Your details<br /><asp:HyperLi nk ID="ancPersonal "
runat="server"> <asp:Image ID="imgHelpPers onal" runat="server" /></
asp:HyperLink></div>
<div runat="server" id="divStep3" class="stepInde x">Step 3<br /
>>Travel Info<br /><asp:HyperLi nk ID="ancTravel"
runat="server"> <asp:Image ID="imgHelpTrav el" runat="server" /></
asp:HyperLink></div>
<div runat="server" id="divStep4" class="stepInde x">Step 4<br /
>>Employer<br /><asp:HyperLi nk ID="ancEmp" runat="server"> <asp:Image
ID="imgHelpEmp " runat="server" /></asp:HyperLink></div>
<div runat="server" id="divStep5" class="stepInde x">Step 5<br /
>>Summary</div>
<div runat="server" id="divStep6" class="stepInde x">Step 6<br /
>>Complete</div>
</asp:Panel>
<asp:contentpla ceholder id="ContentPlac eHolderRegister "
runat="server">
</asp:contentplac eholder>
</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="stepInde x">
i've worked it out:

Dim divStep1 As HtmlGenericCont rol =
CType(Master.Ma ster.FindContro l("ContentPlace Holder1").FindC ontrol("divStep 1"),
HtmlGenericCont rol)

May 1 '07 #4

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

Similar topics

4
2462
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 nested master page between the content page and the top level master? For example, assume the very top level master is called CompanyWide.master. And the nested master page is called DepartmentA.master, which inherits from CompanyWide master. ...
0
924
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 reference those ASP controls. In the debugger, it shows that master (b) only contains 1 control in the Controls collection and that single control is a reference to master (a)! The debugger also shows the ASP controls as members of master (b),...
1
1636
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 Master.Master.PropertyName (for the parent master page). The solution compiles and the HTML looks right, but my code has blue "error" underlines wherever I type Master.Master.PropertyName. When I hover over the underlined code, I get the...
1
1819
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 ControlObject.Style.Add("Left", "100")
6
3265
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 Page_Load() event <code> private void ConfigureFormControls() { Color borderColor = ColorTranslator.FromHtml("#F5F5F5"); Color fontColor = borderColor;
4
1884
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. Is there a way that I can define a common template / etc where this code can live 1 place and then I can just use it / insert it onto these ten pages? So for example if you wanted to put 4 text boxes on 10 pages with the 4 text boxes exactly...
4
2688
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 have become very long since we have 2 master pages that our pages inherit from. Some team members at
1
2058
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 DesignTime master is a single level master page incorporating both the content of the MasterPage and the SubMaster, so that I can get around the fact that you can't see content pages in Design mode if they use nested masters.
5
2707
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 file is added by the webcontrol. This prevents me having to remember to add the CSS file to the page if I use a certain webcontrol. I have a MasterPage with an array of StyleSheets, and a public function for
0
8305
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8823
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8730
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8605
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7321
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6163
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4151
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1607
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.