与发行对象GetLocalResource [英] Issue with GetLocalResource object

查看:105
本文介绍了与发行对象GetLocalResource的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图访​​问我的本地资源文件在我的code-后面。我做了一些谷歌上搜索,因为我是不确定如何做到这一点,发现这一点:

I am trying to access my local resources file in my code-behind. I did some googling since I was unsure of how to do it and found this:

oContent.Text = HttpContext.GetLocalResourceObject("NonSupport").ToString();

不过,我得到一个错误说,它至少需要两个参数: VirtualPath 的ResourceKey 。还有第三个,的CultureInfo ,但一个是可选的。当我把这个作为我的虚拟路径:

However, I get an error saying that it needs at least two parameters: VirtualPath and ResourceKey. There is a third, CultureInfo but that one is optional. When I put this in as my virtual path:

HttpContext.GetLocalResourceObject("App_LocalResources/ExpandableListView.aspx.resx", "NonSupport").ToString();

我得到以下编译器错误消息:

I get the following compiler error message:

相对虚拟路径App_LocalResources文件/ ExpandableListView.aspx.resx在这里不允许。

The relative virtual path 'App_LocalResources/ExpandableListView.aspx.resx' is not allowed here.

我必须做一些不对的,因为我的搜索(和一些帖子,我发现放在这里)说,所有我需要做的就是调用的资源键。

I must be doing something wrong with this since my searches (and some posts I found on here) say all I need to do is call the resource key.

有什么想法?谢谢!

推荐答案

你把一个资源文件名为(您的ASPX网页).aspx.resx 进入一个 App_LocalResource 在您的ASPX页面的生活??路径下的文件夹

Did you put a resource file with the name (your aspx web page).aspx.resx into a App_LocalResource folder underneath the path where your ASPX page lives??

此外,只需简单地调用 GetLocalResourceObject 法在当前页面上:

Furthermore, just simply call the GetLocalResourceObject method on your current page:

oContent.Text = GetLocalResourceObject("NonSupport").ToString();

没有必要使用的HttpContext为 - 该方法被定义在

No need to use HttpContext for that - the method is defined on the Page class.

马克

这篇关于与发行对象GetLocalResource的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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