我的项目中有几个布局(母版页),我想根据共享的部分页面所使用的布局来做一些条件。有没有办法获取这些部分使用的布局页面?
到目前为止,我已经尝试过:
@{
if (Layout == "_MasterPage") //layout always come as NULL, even thought it is being used correctly
}
还有其他方法可以检查所使用的布局吗?
答案 0 :(得分:0)
"Is there any other way to check for the Layout used?"
Yes, there is. You can use a specific model (and use regular OOP inheritance) and check in your partial, for instance.
Also, it feels like a hack, but nothing is stopping you from defining a cookie or something when using one master page or the other and checking that inside your partial.