Databinding expression not evaluated - problem

M

mikeon

Hello!

I have an aspx page with 4 images on it:

<img src="<%# ImageUrl %>" />
<img src="x<%# ImageUrl %>" />
<img src="<%# ImageUrl %>" runat="server" ID="Img1"/>
<img src="x<%# ImageUrl %>" runat="server" ID="Img2"/>

Assume that my code behind file has ImageUrl property defined and that
I call DataBind() method when needed.

I wonder if any of You would guess which one of the above images would
have its src attribute set correctly?

I thought that all of them, but I was wrong. It appears that what I get
is:
<img src="image.gif" />
<img src="ximage.gif" />
<img src="image.gif" id="Img1" />
<img src="x<%# ImageUrl %>" id="Img2" />


As You can see, the last expression is not evaluated.
As You can see, the only difference is the use of runat="server"
attribute (id attribute does not matter in this case).

Can somebeody tell me why is it behaving in such a way?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top