Friday, March 23, 2012

image hyperlink in sql database

Hi,

I want to store an image hyperlink in a sql database but don't seem to be able to do it..is this do-able?

I can store a hyperlink in text format, no problem, but how do I do the same with an image?

I want to use images in my images folder. I can create an image field and set the required options to display images all that is pretty straight forward but trying to display the image as a hyperlink ( actually it's a mailto: link I want to use) seems not to be an option.

The purpose of this is to allow users to upload an image together with their email address and when other users click on the image it fires up their email app. I do not want to have to use a text link.

Thanks

Hi, it is doable. You can use Hyperlink server control to achieve it.

<asp:HyperLink id="hlImageLink" runat="server"/>

In code behind,

hlImageLink.NavigateUrl = String.Format("mailto:{0}", DataReader["emailAddress"]);
hlImageLink.ImageUrl = String.Format("getimage.aspx?id={0}",DataReader["id"]);

You need the getimage.aspx to retrieving the image from the DB and render it as stream. Check thishttp://www.odetocode.com/Articles/172.aspx

Hope this helps..

|||

Hi

Thanks for your reply ...that sounds like it will do the trick!

Malc

No comments:

Post a Comment