The tags <%# %>
are used to data linkage, and therefore it is necessary that the code execute the binding (DataBind()
) in case it is not done automatically (as in the data binding controls). You can choose to use tags <%: %>
, without the need to use the second code block that is in the statement of your question.
In case, the code would look like this:
<script src="<%: ResolveUrl("~/Scripts/jquery-1.11.1.js") %>" type='text/javascript'></script>
<script src="<%: ResolveUrl("~/Scripts/jQuery-Mask-Plugin.js") %>" type='text/javascript'></script>
<script src="<%: ResolveUrl("~/Scripts/jQuery-Formatacao.js") %>" type='text/javascript'></script>
<link href="<%: ResolveUrl("~/Styles/estilo.css") %>" rel='stylesheet' type='text/css' />
In case of future doubts, here is the explanation of how the ASP.NET tags work:
<% %>
defines a server code block that is executed during page rendering. You can execute statements and call methods from the page class the block is inserted in (http://msdn.microsoft.com/en-us/library/ms178135%28v=vs.100%29.aspx).
<%= %>
functions as a Response.Write()
, most useful for displaying unique information (http://msdn.microsoft.com/en-us/library/6dwsdcf5%28VS.71%29.aspx).
<%# %>
defines a data binding expression (http://msdn.microsoft.com/en-us/library/ms178366%28v=vs.100%29.aspx).
<%$ %>
defines an ASP.NET expression (http://msdn.microsoft.com/en-us/library/d5bd1tad%28v=vs.100%29.aspx).
<%@ %>
defines a directive expression (http://msdn.microsoft.com/en-us/library/xz702w3e%28VS.80%29.aspx).
<%-- --%>
sets a block of comments on the server side (http://msdn.microsoft.com/en-us/library/vstudio/4acf8afk%28v=vs.100%29.aspx).
<%: %>
works like the <%= %>
, but encodes the output in HTML (http://weblogs.asp.net/scottgu/new-lt-gt-syntax-for-html-encoding-output-in-asp-net-4-and-asp-net-mvc-2).
You can check more details of these expressions in:
http://support.microsoft.com/kb/976112
Reference
Based on mbanavige user response in ASP.NET forums.
<URL: http://forums.asp.net/t/1139381.aspx>
Thank you very much, very enlightening the post. In the example you used the "#" for <%# Resolveurl("~/Scripts/jquery-1.11.1.js") and the ":" for the others, it was some mistake or has to be anyway?
– Jothaz
Oops, it was a mistake. I’m sorry.
– Guilherme Portela
Thank you again!
– Jothaz