Solved

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

Posted on 2011-09-23
3
471 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

896 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now