我有一些文本内容,我希望能够在不重新编译我的项目的情况下进行更改。我创建了一个资源文件并在其中放入了一些文本内容。
我的印象是我可以写 <%$ Resources:mapLink2 %> 任何我想要的地方,但似乎并非如此。
我的 ascx 中的以下代码给了我一个错误:
<a href="<%$ Resources:mapLink2 %>"><img class="2 selectableImg" src="map_2.gif" /></a>
我只收到瑞典语的错误消息(对此感到抱歉),但我认为它可能会给你一些关于正在发生的事情的提示:
Literala uttryck som "" är inte tillåtna。Använd 我 stället。vid System.Web.UI.TemplateParser.ProcessError(String message) vid System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding) vid System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding )
但如果我这样做:
<a href='<asp:literal runat="server" Text="<%$ Resources:mapLink2 %>"/>'><img class="2 selectableImg" src="map_2.gif" /></a>
一切正常。
第一个版本怎么不行?资源文件不应该像我希望它们在示例 1 中那样工作吗?