Asp.net is reading from another local resource

I have local resource files, for example in a screenshot:

enter image description here

How to read local resource data on the AddCustomer page on the Default.aspx page?

Thanks!

+4
source share
3 answers

Finally found:

HttpContext.GetLocalResourceObject(virtualPath, resourceKey) 
+6
source

Read the file in StreamReader.

 StreamReader SR; SR = File.OpenText(Server.MapPath("~/App_globalResources/Litware.resx")); string str = SR.ReadToEnd(); SR.Close(); 
+2
source

Maybe you should consider using the global resources file, if that makes sense, and access it anywhere on the page through Resources.MyGlobalResxFile.MyString as you can already read .

Otherwise, I believe that you should avoid this if you plan to access the local resource on another page just because it happens that several lines are the same. You are better, I think, if you simply duplicate these lines and keep the resource dependencies on each page separately from each other and therefore cleaner to maintain

0
source

Source: https://habr.com/ru/post/1341447/


All Articles