[英]Why to use # in embedded code asp.net
when to use #
used inside <% %>
? 何时使用
#
在<% %>
内部使用?
<%# Eval()%>
what is the use of #
in this ? <%# Eval()%>
在此使用#
是什么?
what are the other options available like this? 像这样的其他可用选项是什么?
<%#%>
is known as the binding expression. <%#%>
被称为绑定表达式。 The data-binding expressions can be used in attributes of server tags to assign calculated values to properties. 数据绑定表达式可用于服务器标签的属性中,以将计算出的值分配给属性。 Also they can be used like a separate tag.
它们也可以像单独的标签一样使用。
You may check MSDN for details 您可以检查MSDN以获得详细信息
<%# ... %>
<%#...%>
The data-binding expression creates binding between a server control property and a data source when the control's DataBind method of this server control is called on the page.
当在页面上调用此服务器控件的控件的DataBind方法时,数据绑定表达式将在服务器控件属性和数据源之间创建绑定。
The following example shows how to use the data-binding expression to bind the string from a function to the Text property of a label: 下面的示例演示如何使用数据绑定表达式将字符串从函数绑定到标签的Text属性:
<%@ Page Language="VB" %>
<script runat="server">
Protected Function SayHello() As String
Return "Hello World"
End Function
Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs)
lblHello.DataBind()
End Sub
</script>
<html>
<body>
<form id="form1" runat="server">
<asp:Label ID="lblHello" runat="server" Text="<%# SayHello%>"></asp:Label>
</form>
</body>
</html>
what are the other options available like this?
像这样的其他可用选项是什么?
From the same MSDN site. 来自同一MSDN站点。 You may find the option like:-
您可能会发现以下选项:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.