如何从视图中获取母版页的路径,我认为
((WebFormView)Html.ViewContext.View).MasterPath
可以做到这一点,但不幸的是,它总是空着的。
所以我怎么得到它?
答案 0 :(得分:1)
我不确定你需要什么,但是View应该有一个MasterPageFile属性,它包含MasterPage的相对路径。如果需要物理位置,可以使用MapPath。
<%= this.MasterPageFile %>
<%= MapPath( this.MasterPageFile ) %>