【问题标题】:Why is ViewContext.ViewName not available?为什么 ViewContext.ViewName 不可用?
【发布时间】:2011-01-03 20:37:59
【问题描述】:

我在网上阅读了几个使用以下代码的示例:

Private Function SomeFunction(ByVal htmlhelper As HtmlHelper) As String
    Dim controller As Controller = htmlhelper.ViewContext.Controller

    If controller IsNot Nothing Then
        Dim vname as String = htmlhelper.ViewContext.ViewName 'This doesnt work
    End If
End Function

ViewContext 没有名为 ViewName 的成员。我错过了什么吗?

参考: http://blog.eworldui.net/post/2008/05/ASPNET-MVC---Localization.aspx
Asp.Net MVC: How to determine if you're currently on a specific view
http://groups.google.com/group/spark-dev/browse_thread/thread/e5d9e8264c66ba57

【问题讨论】:

  • 在我的助手模块中...这是一个助手函数。 (但它甚至没有编译...)

标签: asp.net-mvc vb.net viewcontext


【解决方案1】:

看起来ViewName 在测试期间被删除了。这里有两个解决方法:

http://forums.asp.net/p/1334617/2694729.aspx

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-10-05
    • 2023-02-01
    • 1970-01-01
    • 2020-03-20
    • 1970-01-01
    • 2018-03-20
    • 1970-01-01
    相关资源
    最近更新 更多