I have a problem with how ASP.Net generates the img tag. I have a server control like this:
<asp:Image runat='server' ID='someWarning' ImageUrl='~/images/warning.gif' AlternateText='Warning' />
I expect it to generate this:
<img id='ctl00_ContentPlaceHolder1_ctl00_someWarning' src='../images/warning.gif' />
but instead it generates this:
<img alt='' src='/Image.ashx;img=%2fimages%2fwarning.gif'</img>
This give me errors when I execute the following js:
document.getElementById('ctl00_ContentPlaceHolder1_someWarning')
Any idea why it won’t generate the expected html?
Looks like it’s trying to use a custom handler (ashx) to deliver the image. Do you have any additional modules that may be overriding the default behaviour of the asp:Image?
Your JavaScript won’t work because the image tag has not been given an ID in the HTML that was generated.