0

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..

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Kokila
  • 997
  • 3
  • 8
  • 14

3 Answers3

1

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
Karl Anderson
  • 34,606
  • 12
  • 65
  • 80
0

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" />
Community
  • 1
  • 1
BentOnCoding
  • 27,307
  • 14
  • 64
  • 92
  • Yes when this is rendered by the server it comes to the client as pure html, so you can do whatever you need with html elements. This is merely a mechanism to inject server side variables into your html. – BentOnCoding Aug 28 '13 at 12:08
  • But how to add the img tag? Should i close the server tag before using img tag and after the img tag to open the server tag again? If I did so, its throwing error – Kokila Aug 28 '13 at 12:18
  • @Kokila If this answered your questions, please select it as the correct answer. – BentOnCoding Aug 28 '13 at 13:40
0

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

Telerik uses this syntax for code templates

Joan Caron
  • 1,969
  • 18
  • 21