Last active
July 18, 2019 13:11
-
-
Save jasonicarter/a267c7360a6e27487bd7 to your computer and use it in GitHub Desktop.
Determine if your ASP.NET Sitecore placeholder has any controls in it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="main"> | |
<sc:Placeholder id="myPlaceHolderID" key="myPlaceHolderKey"></sc:Placeholder> | |
</div> | |
//Problem: How do I know if my placeholder is empty? | |
//#1 | |
var controlCnt = Sitecore.Context.Page.Renderings.Count( | |
r => r.Placeholder.IndexOf("myPlaceHolderKey", StringComparison.OrdinalIgnoreCase | |
) > -1); | |
//#2 | |
myPlaceHolderID.Controls.Count <= 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you! This was exactly what I needed. Appreciate it very much. :)