Saturday, March 24, 2012

Working with ImageUrl

I am trying to set the ImageUrl property of the Image server control, within the HTML code, as follows:

<asp:image id="Image1" ImageUrl='http://localhost/projectname/images/<%#DataBinder.Eval(Container.DataItem, "ImageUrl") %>' .... >

However, this does not seem to be working. The image is not being displayed. If I click on the image properties (within IE), the following url is being used for the image, which is clearly wrong:

http://localhost/viamedonline/images/products/<%# DataBinder.Eval(Container.DataItem, "ImageUrl") %>

So, Why the ImageUrl of the Image control not being set properly??

(I also want to have the ability to turn off / on this image. This is why I am using a Image control, otherwise, I could use a standard image tag)

thanks

try this code (In VB.NET, if you're using C# replace the & with +

<asp:image id="Image1" ImageUrl='<%# "http://localhost/projectname/images/" & DataBinder.Eval(Container.DataItem, "ImageUrl") %>' .... >


Hello, please try to use this:

<pre>
<asp:image id="Image1" ImageUrl="<%#http://localhost/projectname/images/DataBinder.Eval(Container.DataItem, 'ImageUrl') %>" .... >
</pre>

OR

<pre>
<asp:image id="Image1" ImageUrl='<%#http://localhost/projectname/images/DataBinder.Eval(Container.DataItem, "ImageUrl") %>' .... >
</pre>

regards


Jazak-allah both of u (if u know what that means) otherwise 'thanks u'
Yeah I know what it meansSmile [:)], and bilal does too...

Shot in the dark, but I reference all "imageURL=" wth ..:
ImageUrl='../images/<%#DataBinder.Eval(Container.DataItem, "ImageUrl") %>' .... >

Use the above if the code is in a control in a sub-directory.

Use the following if the contol or aspx file is in the root:

ImageUrl='images/<%#DataBinder.Eval(Container.DataItem, "ImageUrl") %>' .... >

I will try and check other stuff to see why the script part is not evaluating.


Hello Hassan, for sure I know what you mean as Wissam said. Best regards to you my friend Wissam. Hope we were able to help.

God be with you all.

Best Regards

0 comments:

Post a Comment