Search code examples
asp.nethtmlvb.netcode-behind

How to access non-asp <img> tag from code behind?


We're working on a big project and we're stuck a bit here. I need to access the <img>'s from an .ASPX from the code-behind on the PageLoad() to assign the right image (attrib src) depending on the value we just collected from the DB from an SQL Query.

We can't use the runat="server" attribute to see it server side because we got a bunch of jQuery using the img name tag to work with.

I'm sure there's a way to access and modify the src attribute of the images from the code behind view?


Solution

  • You can use a Literal control to output the image element.

    You can access the value of the literal to extract (parse out) any information from it and re-write it.