0

我有以下文件: View.ascx, View.ascx.cs, View.ascx.resx 。在文件 View.ascx.resx 中,我在EmailAddress.Text从后面的代码中读取键的值时遇到了很多麻烦。

我试过这个:

  object keyValue = System.Web.HttpContext.GetLocalResourceObject("~/View.aspx", "EmailAddress", culture);
  EmailAddress.Attributes["placeholder"] = keyValue.ToString();

它给了我错误:

Error: Contact is currently unavailable. DotNetNuke.Services.Exceptions.ModuleLoadException: The resource class for this page was not found. Please check if the resource file exists and try again. ---> System.InvalidOperationException: The resource class for this page was not found. Please check if the resource file exists and try again. at System.Web.Compilation.LocalResXResourceProvider.CreateResourceManager() at System.Web.Compilation.BaseResXResourceProvider.EnsureResourceManager() at System.Web.Compilation.BaseResXResourceProvider.GetObject(String resourceKey, CultureInfo culture) at System.Web.Compilation.ResourceExpressionBuilder.GetResourceObject(IResourceProvider resourceProvider, String resourceKey, CultureInfo culture, Type objType, String propName) at System.Web.HttpContext.GetLocalResourceObject(String virtualPath, String resourceKey, CultureInfo culture) at com.John.Contact.View.Page_Load(Object sender, EventArgs e) in C:\Users\john\Documents\My Web Sites\v624\DesktopModules\Contact\View.ascx.cs:line 74 --- End of inner exception stack trace ---

我试过这个:

            ResourceManager rm = new ResourceManager("items", System.Reflection.Assembly.GetExecutingAssembly());
            String r = rm.GetString("EmailAddress");

它给了我这个错误:

Error: Contact is currently unavailable. DotNetNuke.Services.Exceptions.ModuleLoadException: Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "items.resources" was correctly embedded or linked into assembly "Contact" at compile time, or that all the satellite assemblies required are loadable and fully signed. ---> System.Resources.MissingManifestResourceException: Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "items.resources" was correctly embedded or linked into assembly "Contact" at compile time, or that all the satellite assemblies required are loadable and fully signed. at System.Resources.ManifestBasedResourceGroveler.HandleResourceStreamMissing(String fileName) at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark& stackMark) at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark) at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents) at System.Resources.ResourceManager.GetString(String name, CultureInfo culture) at System.Resources.ResourceManager.GetString(String name) at com.John.Contact.View.Page_Load(Object sender, EventArgs e) in C:\Users\john\Documents\My Web Sites\v624\DesktopModules\Contact\View.ascx.cs:line 80 --- End of inner exception stack trace ---

我尝试了 asp.net 代码库中的其他几个示例,但不断收到其他错误。如何从 View.ascx.resx 文件中获取值?

4

1 回答 1

0

好的,终于想通了。我必须使用 DotNetNuke API,因为这是一个 DotNetNuke 项目。

String s = DotNetNuke.Services.Localization.Localization.GetString("EmailAddress",this.LocalResourceFile);
于 2013-09-09T01:18:37.913 回答