I have a C# method called imageResize which I can call from the aspx web-form page:
<%# imageResize(trustPilot,100,111) %>
// Outputs string
But if I try to call it inside an html tag there is no output?
<div class="reviews-graphic" style="background-image: url(<%# imageResize(trustPilot,100,111) %>);"></div>
// No output
Any idea what's wrong?
You can add id and runat attributes to div and add style from code behind:
<div id="divReviews" runat="server" ...>
....
</div>
server side:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
var imgUrl = string.Format("url({0})", imageResize(trustPilot, 100, 111));
divReviews.Style.Add(HtmlTextWriterStyle.BackgroundImage, imgUrl);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With