We help IT Professionals succeed at work.

alternate image in imagefield

Netlink2
Netlink2 asked
on
786 Views
Last Modified: 2012-06-27
Hi experty type ppl,

If an image doesn't exist I'd like to replace it with a default image. The following is the code I have.

<asp:ImageField DataImageUrlFormatString="~/PhotoDisplay.ashx?photoid={0}&amp;size=small"
DataImageUrlField="PreviewImageId" SortExpression="PreviewImageId" AlternateText="No Photo.">
      <ItemStyle CssClass="col_photo" />
      <HeaderStyle CssClass="col_photo" />
</asp:ImageField>
Comment
Watch Question

Top Expert 2007

Commented:
The subsititution of the defualt image would best be done in your handler.

Purists would also say that Alternate Text should describe the image (for text readers) not be used in the absence of a valid image.
Top Expert 2007
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
I ended up using codebehind with vb to see if the file exists. Your suggestion pointed me in the right direction.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.