I've been using the repeater control in asp.net for awhile now..and every now and then i keep forgetting to add the '#' inside the < %# DataBinder.Eval(Container.DataItem, "NAME") % >
so i was wondering what does it mean ?
It is indicating that you are binding an expression so as you demonstrated eval or bind.
Data-Binding Syntax
Data-binding expressions are contained within <%# and %> delimiters and use the Eval and Bind functions. The Eval function is used to define one-way (read-only) binding. The Bind function is used for two-way (updatable) binding. In addition to calling Eval and Bind methods to perform data binding in a data-binding expression, you can call any publicly scoped code within the <%# and %> delimiters to execute that code and return a value during page processing.
just to add...
you also have:
$
let's you Bind a Resource, like:
<%$ Resources:Menu, oktext %>
=
the most known binder sign, let's you do the same as the Response.Write method
<%= myVariable %> instead <% Response.Write(myvariable) %>
New to .NET 4.0 there is
:
which is just like the <%= %>
but HTML encodes your output. It is used like:
<%: Model.Name %>
And it is just like calling
<%= HttpServerUtility.HtmlEncode(Model.Name) %> .. or ..
<% Response.Write(HttpServerUtility.HtmlEncode(Model.Name)) %>
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