如何在服务器端控件中实现 eval 脚本?
例如。 ">hello world
">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>
<a runat="server" href="?id=<%= Eval("Id") %>">hello world</a>
如果服务器端控件位于数据绑定控件(ListView、GridView、FormView、DetailsView)内,则语法为:<%# Eval("Id") %>。
<%# 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.
据我所知,它是 <%# 而不是 <%=
as far as I know, its <%# instead of <%=
数据绑定表达式是您的朋友,请参阅 MSDN 了解示例。
The Data-Binding expression is your friend, see MSDN for examples.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
暂无简介
文章 0 评论 0
接受
发布评论
评论(3)
如果服务器端控件位于数据绑定控件(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.
据我所知,它是 <%# 而不是 <%=
as far as I know, its <%# instead of <%=
数据绑定表达式是您的朋友,请参阅 MSDN 了解示例。
The Data-Binding expression is your friend, see MSDN for examples.