tags:

views:

34

answers:

1

I have user control under Sitecore CMS. It has some controls bound to some fields of context. For example:

<sc:text runat="server" field="HomePage_WelcomeText"></sc:text>

I have different content items based on the same template and I need to change context to some of them in PageLoad(). For example, if URLRefferer has certain value I want to have certain content item in context.

Any hints?

+3  A: 

The sc:text control has a public property called 'Item' that takes a Sitecore.Data.Items.Item. So, give your control an ID attribute, then on Page_Load you can dynamically set that Item property as needed.

<sc:text id="myTextControl" runat="server" field="HomePage_WelcomeText" />

protected void Page_Load(object sender, EventArgs e)
{
    Sitecore.Data.Items.Item myItem = Sitecore.Context.Database.GetItem("/sitecore/content/home");
    myTextControl.Item = myItem;
}
Sean Kearney
Thanks, that is exactly what I need!
DixonD