.NET Framework Developer Center > .NET Development Forums > Chart Controls for .NET Framework > Reference a control with .FindControl(...) from the Master Page Code-behind, to a control in the Content Page
Ask a questionAsk a question
 

AnswerReference a control with .FindControl(...) from the Master Page Code-behind, to a control in the Content Page

  • Tuesday, November 03, 2009 8:14 PMAcaspita Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi there!
             If it´s not clear in the title, what I'm trying to do is to reference a control that is located in a page that implements a master page, but the code is executed from the Master Page Code-behind (it has to be there, or else I have to copy it in each content page).
             The code that makes this is the following:

                    SiteMapDataSource ds = (SiteMapDataSource)Page.FindControl("SiteMapDataSourceMain");
                    ds.SiteMapProvider = newValue;

             The id of the control that I need is "SiteMapDataSourceMain", and this control exists, nevertheless, ds remains nul.
             For me this code is fine, so... What am I doing wrong?

                      Thanks! Cheers!
                                               Leandro
    Acaspita

Answers

All Replies