What does the <#= symbol mean?

661 Views Asked by At

What <# this symbol means in the asp.net It is inside the html tag.

 <td><#= userInfo.observerResponseKey != null ? (userInfo.observerStatus == '<%= Enum.GetName(typeof(Status), Status.Draft) %>' ? "Draft shared " +  userInfo.observerDateSubmittedString : userInfo.observerStatus == '<%= Enum.GetName(typeof(Status), Status.Private) %>' ? "In Progress" :  "Completed " + userInfo.observerDateSubmittedString) + " by " + userInfo.observerName : "Not Started"  #></td>

I want to add img to the td if the result is "In progress" or "completed".

I tried adding like

 <td><#= userInfo.observerResponseKey != null ? (userInfo.observerStatus == '<%= Enum.GetName(typeof(Status), Status.Draft) %>' ? "Draft shared " +  userInfo.observerDateSubmittedString : userInfo.observerStatus == '<%= Enum.GetName(typeof(Status), Status.Private) %>' ? "In Progress" :  "Completed " + userInfo.observerDateSubmittedString) + " by " + userInfo.observerName #><img src="../../images/icon_delete_red.png" /> <#= : "Not Started"  #></td>

But its throwing error "Unparse Microtemplate"

So, what is that tag <#= mean? and how can I add an image in this code?

Please help me..

3

There are 3 best solutions below

3
On

It's a code block or a "code nugget". Essentially it allows you to embed code to be processed and rendered by the server before being sent to the client.

See this .NET "code nugget blocks"?

or

What are these called in ASP.NET <%: %>?

An example :

<img id="<%= someValue.ToString() %>" src"http://website.com/someImg.jpg" />
0
On

http://demos.telerik.com/aspnet-mvc/razor/grid/templatesclientside

Telerik uses this syntax for code templates

1
On

Embedded code blocks.

<%# %> is for data-binding expressions

For example, in an ASP.NET GridView, many times you will see something like this:

<%# Eval("DataColumnName") %>

There are several other varieties of these:

<%= %> is the equivalent of `Response.Write()`
<% %> runs server-side code, like an if-else block
<%: %> is for HTML-encoding the data
<%@ %> is for directives, usually page directives in ASP.NET