0

I have a master page in Sitecore using sublayout:

 <sc:Sublayout id="slTop" runat="server" Path="...">

I would like to access a control inside this sublayout from layout page (.aspx) that uses the same master page. I have tried something like

Master.FindControl("slTop").FindControl("htmlControl")

but it returns null, possibly because the controls are not public.

Master.FindControl("slTop").Controls

is also empty.

I would like to hide this control. Is it possible?

lyrikk
  • 15
  • 5
  • Don't use Masterpages in Sitecore like you would in traditional ASP.Net, use `Layouts` instead: http://learnsitecore.cmsuniverse.net/en/Developers/Articles/2010/03/Sitecore-simple-layout.aspx Even then, accessing controls in this way is tough, your components should be self contained pieces of logic. – jammykam Apr 18 '15 at 09:23

1 Answers1

0

You can use javascript function to hide this control and call this javascript function via layout(master page).

<script>
    function hidesltop(){
       $("#slTop").css('display','none');
    }
</script>

In your layout(master page) you can call this function as

 ScriptManager.RegisterStartupScript(this, GetType(), "hidesltop", "hidesltop();", true);
Sachin B. R.
  • 941
  • 4
  • 16
  • 30