简体   繁体   English

<#=符号是什么意思?

[英]What does the <#= symbol mean?

What <# this symbol means in the asp.net It is inside the html tag. <#这个符号在asp.net中的含义它在html标记内。

 <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". 如果结果是“进行中”或“完成”,我想将img添加到td。

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" 但是其抛出错误“ 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: 例如,在ASP.NET GridView ,很多时候您会看到类似以下内容:

<%# 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"? 看到这个.NET“代码块块”吗?

or 要么

What are these called in ASP.NET <%: %>? 这些在ASP.NET <%:%>中被称为什么?

An example : 一个例子 :

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

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

Telerik uses this syntax for code templates Telerik使用此语法作为代码模板

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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