开发者

asp.net read from other local resource

I have local resources files like on screenshot:

asp.net read from other local resource

How can I read local resource data of AddCustomer page in Default.aspx page?

Thank开发者_Go百科s!


At last found it:

HttpContext.GetLocalResourceObject(virtualPath, resourceKey)


Read the file in a StreamReader.

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


May be you should consider using a global resource file if it makes sense, and access it anywhere in a Page through Resources.MyGlobalResxFile.MyString as you may have already read.

Otherwise I believe you should avoid this if you are considering to access a local resource on a different page only because it so happens that a couple of strings are the same. You are better off I think if you just duplicate those strings and keep resource dependencies on each page separate from one another and thus cleaner to maintain

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜