有没有办法知道子布局通过代码坐在哪个占位符?
场景:如果它位于占位符B而不是占位符A,我希望子布局看起来有点不同.我可以使用子布局参数执行此操作,但我试图使其成为一个作者,因此作者不必设置值而不是子布局足够聪明,可以知道它正在使用的上下文.
您可以使用规则引擎做一些聪明的事情,这可能就是我要解决的问题 - 可能使用基于占位符的规则引擎更改渲染参数,然后根据该代码在代码中执行某些操作...
但您可以从代码中执行以下操作:
Sublayout sublayout = this.Parent as Sublayout;
if (sublayout != null)
{
Placeholder placeholder = sublayout.Parent as Placeholder;
if (placeholder != null)
{
// name of the container placeholder
string placeHolderKey = placeholder.Key;
// full path of nested placeholders
string placeHolderContextKey = placeholder.ContextKey;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2269 次 |
| 最近记录: |