asp.net - 带有条件运算符的 asp.net <%$ ... %> 语法
问题描述
<asp:Button ID="SubscribeButton" runat="server" CssClass="PopupButton" Text='<%# Eval("Payment_Method_Tkn").ToString() != "" ? "Unsubscribe" : "Subscribe" %>'/>
完美运行。
<asp:Button ID="SubscribeButton" runat="server" CssClass="PopupButton" Text="<%$ Resources:P2CWebStrings, UnsubscribeButtonLabel %>"/>
也可以正常工作,正确地从资源文件中获取值
然而:
<asp:Button ID="SubscribeButton" runat="server" CssClass="PopupButton" Text='<%# Eval("Payment_Method_Tkn").ToString() != "" ? "<%$ Resources:P2CWebStrings, UnsubscribeButtonLabel %>" : "<%$ Resources:P2CWebStrings, SubscribeButtonLabel %>" %>' />
在屏幕上显示“<%$ Resources:P2CWebStrings, UnsubscribeButtonLabel %>”而不是资源文件值。任何想法如何解决它,请。
解决方案
这是正确的语法:
<asp:Button ID="SubscribeButton" runat="server" CssClass="PopupButton" Text='<%# Eval("Payment_Method_Tkn").ToString() != "" ? GetGlobalResourceObject("P2CWebStrings", "SubscribeButtonLabel") : GetGlobalResourceObject("P2CWebStrings", "UnsubscribeButtonLabel") %>'/>
推荐阅读
- python-3.x - 在这样的短期课程中上课有什么好处
- python - 在具有不同大小和相似匹配的字符串中查找完全匹配
- c# - 如何更改按钮事件中标签的文本?
- html - 在不同类型的按钮之间切换
- php - 使用 google 联系人 api 更改联系人的问题
- git - “git log --diff-filter=R”和“git log --find-renames”有什么区别?
- javascript - Chrome 性能 DevTools 中不明确的“任务”
- javascript - 如何在 React Native 中创建 64 位 apk
- javascript - JavaScript 开始使用正则表达式和偏移量
- excel - 如何修复跳过某些值的 for 循环?