November Happy Hour will be moved to Thursday December 5th.

Determine property name from DynamicContentPlugIn instance

Vote:
 

I have WebControl that inherits from UserControlBase lets call it "MyDynamicControl",

I have specified attribute for it: DynamicContentPlugIn.

 

The question is: from DynamicContentPlugIn control how can I determine name of property in what this instance resides?

 

Why I need this:

For example in property named "A" I add "MyDynamicControl", that displays content from property "B", and it works fine.

But if user places "MyDynamicControl" inside property named "A" and configures to display property "A"(the same property) then infinite loop happens(and it should happen).

 

#55287
Nov 25, 2011 13:25
Vote:
 

Probably may not working in all cases but this code snippet gave me outer property name in which dynamic content control is included (code behind of .ascx user control).

 

var container = BindingContainer;
if (container != null)
{
    var mainContainer = container.BindingContainer as EPiServer.Web.WebControls.Property;
    if(mainContainer != null)
    {
        // you logic here
    }
}

    

#55298
Edited, Nov 27, 2011 19:33
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.