i have certain element in a asp.net control:
<a href="#" title="" style="background-image: url('../i/foo/image.png')">
but i want the background-image field being set from a control c# property
what are my options here?
basically i wanted to add something like:
<% if (!string.IsNullOrWhiteSpace(BackgroundImageUrl)) {
{ %>
<a href="#" title="" style="background-image: <%= item.BackgroundImageUrl%>">
<% } %>
but i’m not sure the <%= item.BackgroundImageUrl%> is correctly escaped inside the style property. What is the correct escaping pattern for this?
To make HTML elements programmable, and accessible on the server side, add a
runat="server". Also, make sure the<form>tag has alsorunat="server". Example:On the server side do:
See this website for more details