Escaping inline code block in Asp.Net template

时光怂恿深爱的人放手 提交于 2019-12-06 11:16:50

I ideally wanted to keep it within the aspx page. This is the best solution I could find (from here), which creates splits the closing > into a separate string

<script type="text/html" id="lightbox-template">
 <div id="lightbox-background"></div>
 <div id="lightbox"><%= "<%= content %" + ">" %=><div class="bottom"></div></div>  
</script>

Important bit: <%= "<%= content %" + ">" %=>

This goes into aspx

<div> <%= GetContentString() %>  </div>

This goes into aspx.cs

 protected String GetContentString()
    {
        return "this is a content";
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!