我有以下文件: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文件中获取值?
答案 0 :(得分:0)
好吧终于明白了。我必须使用DotNetNuke API,因为这是一个DotNetNuke项目。
String s = DotNetNuke.Services.Localization.Localization.GetString("EmailAddress",this.LocalResourceFile);