Skip to content

Instantly share code, notes, and snippets.

@islaytitans

islaytitans/SplashPanel.ascx.cs Secret

Created Jul 13, 2015
Embed
What would you like to do?
Splash Panel code behind
public partial class SplashPanel : UserControl
{
private Item _dataSource;
public Item DataSource
{
get
{
if (_dataSource == null)
{
var parent = Parent as Sublayout;
if (parent != null)
_dataSource = Sitecore.Context.Database.GetItem(parent.DataSource);
}
return _dataSource;
}
}
protected void Page_Load(object sender, EventArgs e)
{
titleText.Item = DataSource;
straplineText.Item = DataSource;
clickThroughLink.Item = DataSource;
Sitecore.Data.Fields.ImageField imageField = DataSource.Fields["image"];
dPanel.Attributes.Add("style", "background-image:url(\"" + MediaManager.GetMediaUrl(imageField.MediaItem) + "\")");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment