Copy the Handler.ashx file from the link I gave you above. That's the handler I use and it works great. It's in both VB and C# there. Make sure you put it in the same directory as the page you are going to call it from. In other words if the page your image
tag is at is in the web's root, place the handler.ashx file in the root as well.
Change "ImageId" to whatever your identity column is in your table.
You can play with height and width to get the settings you want, or omit them to display the original image size. I use them for uniformity purposes. Be sure to go through the Handler.ashx and configure it for your connection string and
the identity field in your db table. Mine is ImageId so just change it to whatever yours is.
Have you done View Source in the browser to check if the urls for the images are correct?
Have you used the debugger to see if the code for serving the images executes?
Superguppie.
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
When all you've got is a Hammer, Every Problem looks like a Nail. Michael Swain.
AsPxFrK
Member
232 Points
93 Posts
Re: Inserting image to database
Feb 27, 2012 07:41 PM|LINK
Copy the Handler.ashx file from the link I gave you above. That's the handler I use and it works great. It's in both VB and C# there. Make sure you put it in the same directory as the page you are going to call it from. In other words if the page your image tag is at is in the web's root, place the handler.ashx file in the root as well.
Then, use the following tag:
<asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("ImageId", "Handler.ashx?ID={0}")%>' Height="225px" Width="225px />
Change "ImageId" to whatever your identity column is in your table.
You can play with height and width to get the settings you want, or omit them to display the original image size. I use them for uniformity purposes. Be sure to go through the Handler.ashx and configure it for your connection string and the identity field in your db table. Mine is ImageId so just change it to whatever yours is.
Let me know if you have any trouble.
jabaarali786
Member
61 Points
46 Posts
Re: Inserting image to database
Feb 28, 2012 01:42 PM|LINK
Yeah thanks I have followed that, and the page loads but the images do not display
AsPxFrK
Member
232 Points
93 Posts
Re: Inserting image to database
Feb 28, 2012 07:45 PM|LINK
What is the identity column in your data table?
superguppie
All-Star
48225 Points
8679 Posts
Re: Inserting image to database
Mar 01, 2012 07:44 AM|LINK
Have you done View Source in the browser to check if the urls for the images are correct?
Have you used the debugger to see if the code for serving the images executes?
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
When all you've got is a Hammer, Every Problem looks like a Nail. Michael Swain.
Primillo
Star
8841 Points
1701 Posts
Re: Inserting image to database
Mar 01, 2012 05:30 PM|LINK
Please refer to this sample code C#:
http://www.binaryintellect.net/articles/4dc1cc90-4f07-4026-b2a8-2096e3b53870.aspx
By editing the web.config this app run on asp.net 4.0
Have a class SqlHelper.cs that you can reuse it in a lot of projects.
Primillo
http://www.facebook.com/programandopuntonet
jabaarali786
Member
61 Points
46 Posts
Re: Inserting image to database
Mar 02, 2012 05:07 PM|LINK
Image i believe in the database