为什么 ViewContext.ViewName 不可用?

发布于 2024-08-17 03:46:44 字数 924 浏览 1 评论 0原文

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

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---本地化.aspx
Asp.Net MVC:如何确定您当前是否处于特定视图
http://groups.google.com/group/spark-dev/ browser_thread/thread/e5d9e8264c66ba57

I read several examples on the web which use the following code:

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 does not have a member called ViewName. Am I missing something?

Refs:
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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ぺ禁宫浮华殁 2024-08-24 03:46:44

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

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

It looks like ViewName was removed during the betas. Here's two work-arounds:

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文