[英]how to escape an anchor tag in html which eval
Can you please help in escaping this : 您能帮忙转义一下吗:
<p><%# Eval("Text") + <a class="story-link" href="<%# GetDocumentUrl() %>" target="_self"><%# Eval("ReadFullStoryTitle") %></a> %>
</p>
I have tried like below but its not working : 我已经尝试过像下面,但不能正常工作:
<p><%# Eval("Text") + <a class="story-link" href="'<%# GetDocumentUrl() %>'" target="_self"><'%#Eval("ReadFullStoryTitle") %'></a> %></p>
您可以使用以下方法:
<p><%# Eval("Text") %> <a class="story-link" href='<%# GetDocumentUrl() %>' target="_self"><%#Eval("ReadFullStoryTitle") %></a></p>
You can add the data using javascripts innerText
it will escape them properly. 您可以使用javascripts innerText
添加数据,它将正确地转义它们。
<p id="data"><script>document.getElementById('data') .innerText= '<%# Eval("Text") + <a class="story-link" href="<%# GetDocumentUrl() %>" target="_self"><%# Eval("ReadFullStoryTitle") %></a> %>';</script></p>
You can also use css content
property of after and ::after
as follows 您还可以使用after和::after
css content
属性,如下所示
#data::after{ content: '<%# Eval("Text") + <a class="story-link" href="<%# GetDocumentUrl() %>" target="_self"><%# Eval("ReadFullStoryTitle") %></a> %>'; }
<p id="data"></p>
Or You can use the code in p tag below which is escaped. 或者,您可以使用下面的p标记中的代码进行转义。
<p><%# Eval("Text") + <a class="story-link" href="<%# GetDocumentUrl() %>" target="_self"><%# Eval("ReadFullStoryTitle") %></a> %></p>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.