服务器端控制属性中的 Eval 脚本

发布于 2024-07-05 08:04:33 字数 130 浏览 3 评论 0 原文

如何在服务器端控件中实现 eval 脚本?

例如。 ">hello world

how do i implement an eval script in a sever side control?

eg. <a runat="server" href="?id=<%= Eval("Id") %>">hello world</a>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

知足的幸福 2024-07-12 08:04:33

如果服务器端控件位于数据绑定控件(ListView、GridView、FormView、DetailsView)内,则语法为:<%# Eval("Id") %>

如果服务器端控件不在数据绑定控件内,则必须通过代码隐藏来访问它并在那里设置属性。

If the server-side control is within a databound control (ListView, GridView, FormView, DetailsView), then the syntax is: <%# Eval("Id") %>.

If the server-side control is not within a databound control, you will have to access it via the code-behind and set your attribute there.

沒落の蓅哖 2024-07-12 08:04:33

据我所知,它是 <%# 而不是 <%=

as far as I know, its <%# instead of <%=

勿忘初心 2024-07-12 08:04:33

数据绑定表达式是您的朋友,请参阅 MSDN 了解示例。

The Data-Binding expression is your friend, see MSDN for examples.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文