Possible Duplicate:
What's the difference between <%# %> and <%= %>?
<%$, <%@, <%=, <%# … what's the deal?
I apologise if this is duplicated, but it's infuriatingly difficult to google for.
<%:
is new to .NET 4.0 - it is equivalent to HttpUtility.HtmlEncode(Response.Write())
.
<%=
is older and stands for Response.Write()
only.
<%#
is a binding expression.
Here's a good article on them. In summary:
Page Directive
<%@ Page Language="C#" %>
Rendering Code
<% Response.Write("Hello World!"); %>
<%= SayHello("Ahmed") %>
<%: DateTime.Now.ToString() %>
Expression Syntax
<%$ ConnectionStrings:ConnStrFromWebConfig %>
<%$ AppSettings:ValueFromWebConfig %>
<%$ Resources:Resource, Arabic %>
<%$ RouteValue:year %>
<%$ YourExpressionPrefix : Any %>
Data Binding Syntax
<%# Eval("Name") %>
<%# Bind("Name") %>
<%# XPath ("Name") %>
Comment Server
<%-- <asp:Label runat="server" Text="Label"></asp:Label>-- %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With