c# - 如何从 Default.aspx 文件中的 DB 获取字符串?
问题描述
我正在尝试在弹出窗口内单击按钮时显示消息。一切正常,除了我无法从数据库中获取字符串。
<button type="button" class="btn-outline" data-container="body" data-toggle="popover" data-placement="right" data-content=<% LabelManager.Get("UnitPriceExplanation"); %>>
[?]
</button>
如果我在数据内容中写入随机文本,它将起作用。如果我把<% LabelManager.Get("UnitPriceExplanation");
它不会显示文本。所以它不会响应点击。
LabelManager.Get("UnitPriceExplanation"); 在 Default.aspx.cs 中工作正常。
我的目标是在弹出窗口中从数据库中写入文本。如何从数据库中获取字符串。
解决方案
在 Asp.Net 中,当<% %>
操作员执行一个块时,<%= %>
执行代码并打印结果。您需要使用后者并将其用引号引起来。
data-content="<%= LabelManager.Get("UnitPriceExplanation") %>"
推荐阅读
- python - 使用另一个没有自我的类的 Python 方法
- mongodb - 如何使用 Python 中的结构化火花流使用 ForeachWriter 将行插入到 Mongodb?
- python - ValueError:关闭文件python烧瓶上的I / O操作
- r - 如何使R脚本跳转到下一行?
- mysql - 在一个 SQL 查询中合并两个表中的两列,并使用表中的值作为列名
- typescript - Typescript:属性类型通配符
- android - “重新启动接收器”无法正常工作 android [Xamarin.Android]
- javascript - 设置值属性时无法在文本区域中输入文本 - React
- python-3.x - 带循环的假值
- asp.net - 使用 asp.net websrevices (.asmx) 时是否需要特定权限才能访问特定方法?