简体   繁体   中英

What does the <#= symbol mean?

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

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

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" />

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

Telerik uses this syntax for code templates

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM