简体   繁体   English

如何在VB.NET xml字符串文字中嵌入可变CSS样式?

[英]How do I a embed a variable css style in a VB.NET xml string literal?

I would like to add a variable data to a string literal WITHIN the HTML tag 我想在HTML标记内将变量数据添加到字符串文字中

Dim locationOfImage as string = "http://blahblah......" 
Dim xmlString = _
            <div style="background:url(" <%= locationOfImage  %> ")">
                <h3>Some text</h3>

            </div>

The above does not work, I can't quickly determine how to do this? 上面的方法不起作用,我无法快速确定该怎么做? Is this possible. 这可能吗。 I could achieve what I am attempting to do with a StringBuilder but want to use the xml literal if possible. 我可以实现我尝试使用StringBuilder进行的操作,但如果可能的话,希望使用xml文字。

<div style="<%= String.Format("background:url('{0}')", locationOfImage)  %>">

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

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