Hi folks, another newbie question! Having inherited a website, i am noticing script tags <%# and <%: as well as <%= (which i understand from the old days as Response.Write!)
What are the significance of these?
Refer the post below.
<%@ %> is used for page level directives. (<%@ Control Inherits="MyParentControl" %>)
<% %> is for inclusion of server-side code to the Render() method (<% x = x + 1; %>) of the generated class
<%= %> is equivalent of Response.Write(); call in the Render() method
<%: %> is the same as previous, but the output is HTML encoded (see below)
<%# %> is used for data-binding expressions. 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. In this case a DataBoundLiteralControl
instance is automatically generated for the expression to assign a value to its Text property. These expressions are evaluated and assignments are executed when the DataBinding event is fired for the control that contains data-binding expression, because for
every such a control an event handler is generated of these expressions.
<%$ %> is used for custom expression binding. E.g. for localized string resources. Can only be used in attributes of server tags to assign calculated values to properties. These assignments are added to the OnInit() method of the generated
class. See http://msdn.microsoft.com/en-us/library/d5bd1tad.aspx
<%– –%> is used for server-side comments.
Refer the post below.
Thanks for that, always wondered why i could not search for them too
These are called inline server tags for asp.net.
<%# %> - This is Databinding syntax
<%: %> and <%= %> - Rendering Code
refer below link for more details
They are mostly called as "ASP.NET Inline Expressions in the .Net Framework"
The embedded code block is used to preserve backward compatibility with classical ASP. The code in the block can execute programming statements and call functions in the current page class during the page-rendering phase.
The <%= … %>displaying expression is an equivalent of the embedded code block that contains only the Response.Write(…) statement. This is the simplest way to display information such as a single string, an int variable, or a constant.
The directive expression is the syntax that specifies settings that are used by the page and by user control compilers when they process ASP.NET Web Form (.aspx) pages and User Control (.ascx) files.
The data-binding expression creates binding between a server control property and a data source when the control’sDataBind method of this server control is called on the page.
The expression builder is used to set values of control properties based on the information that is contained in an application’s configuration or resource files.
The server-side comments block lets developers embed code comments in any location of the HTML source of ASP.NET Web Form pages (except for within <script> code blocks). Any content between the opening and closing tags of the server-side comments block
will not be processed on the server or rendered on the resulting page.
Hope this helps.