Solved

Access a H1 tag inside the parent master page thru a content page

Posted on 2011-09-23
3
495 Views
Last Modified: 2012-05-12
I have a H1 tag in the body of my Parent Master Page. My content page is based on nested master page. I am trying to access the H1 tag in this content page using the code behind.

My site it built in asp.net 2.0 and C#.

In the Page_Load of my content page I am trying to access it like this>

HtmlGenericControl h1 = (HtmlGenericControl)Master.Master.FindControl("h1top");
                    h1.InnerText = "this is a test";

Open in new window


Didn't work throws an error


System.NullReferenceException: Object reference not set to an instance of an object.
   at mysite.product.Page_Load(Object sender, EventArgs e) in http://server/TestsiteLatest/browse/product.aspx.cs:line 102

line 102 is h1.InnerText = "this is a test";

where am i making an error in writing the code.

Thanks and appreciate it
0
Comment
Question by:niceoneishere
3 Comments
 
LVL 15

Accepted Solution

by:
Eyal earned 250 total points
ID: 36594336
see this page for detailed instructions of how to do this

http://msdn.microsoft.com/en-us/library/c8y19k6h.aspx
0
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 250 total points
ID: 36599409
In order to use FindControl, the element needs the runat="server" attribute.  I wouldn't think that the <h1> element would have that.
0
 
LVL 1

Author Closing Comment

by:niceoneishere
ID: 37017923
thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question