父视图的名称 [英] parent view's name

查看:48
本文介绍了父视图的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在许多页面中都使用了部分视图,我想知道是否有一种方法可以获取当前包含我的部分视图的父视图的名称?

I have a Partial View used in many pages and I was wondering if there was a way to obtain the name of the Parent View that contains my Partial View currently?

推荐答案

您可以从PartialView中获取控制器和动作:

You can get the controller and action from the PartialView:

<%=ViewContext.RouteData.Values["controller"] %>

<%=ViewContext.RouteData.Values["action"] %>

这是您要找的吗?

如果有帮助,您还可以查看 ViewPath :

You can also look at the ViewPath if it would help:

<%= (ViewContext.View as WebFormView).ViewPath %>

这篇关于父视图的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆