2013-09-09 3 views
0

У меня есть следующие файлы: View.ascx, View.ascx.cs, View.ascx.resx. В файле View.ascx.resx у меня много проблем с чтением значения для ключа EmailAddress.Text из моего кода.Не удалось прочитать значение из View.ascx.resx из кода за

Я попытался это:

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

Хорошо, наконец, понял. Я должен использовать DotNetNuke API, потому что это проект DotNetNuke.

String s = DotNetNuke.Services.Localization.Localization.GetString("EmailAddress",this.LocalResourceFile);