I have user control under Sitecore CMS. It has some controls bound to some fields o开发者_高级运维f 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?
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;
}
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论