I save my images in the database as an OLE Object Data type.How can an image from the database displayed in the tag? Is it also in the 'src' attribute?
In other answer you have been pointed to article explains how to show image in data grid. In general I see here two questions, how to extract an image from the database and how to show it in tag. The article from Andras Toth answer covers both questions. But if you are not going to use grids, you should provide url to the image in tag. Here you can read how to implement generic handler shows an image stored in the database, so you can add url to the image to any tag. Solution depends on your needs.
Related
I am retrieving a binary image from SQL Server and would like to pass this binary image from a GridView control to another page and display by using an Image control. What is the best way to do this?
I have tried to use Http.Utility (encode & decode) and it said URL is too long.
My suggestion is as follows:
1. From the details, it seems that your image is stored as a blob(binary data) in database table.
2. Instead of fetching the blob(binarydata) and passing it to the next page, you can just pass the database ID to the next page.
3. On the next page, make an AJAX request to the .NET server side code (you can put this on page load) and fetch the blob based on the database ID received from the previous page.
4. Then display this image and load it in the HTML div or img tag using the javascript success callback of the ajax request.
By the way, it is recommended to always store images on a filesystem. If you can refactor your server side code to store the images in a directory structure - that would be ideal. It may take lot of changes to your code base. If the images are not too big - you may continue with the existing approach with the solution I suggested. Generally, having large binary data in database tables - could in long term make the queries slower.
You may want to check how to set binary data fetched as an image and set it in html. Please check this link for details: Is it possible to put binary image data into html markup and then get the image displayed as usual in any browser?
When I try to do it I get error like this
To add a data bound (From Database field) Image you should follow this steps.
To Add an External Image you should follow this steps
Or to Embed an Image in a Report you should follow this steps.
Note: I have provided links as I don't know how you want to bind this image in your report.
Reference for Dataset field Image
Hope this will help you. Thanks.
So I have this website where users can post articles, each article containing at least one photo. What I want to do is when I display the list of articles on the website I want to also show a thumbnail next to the articles name.
Here comes the tricky part: the images are not hosted on my server, are simply links hosted on some image-hosting website. Another problem is that I don't know where the images appear in the post (they could be at the beginning, at the end or in the middle of the article).
What would be the best approach to create a thumbnail system in this case?
I was thinking maybe I could do this: every time an article is posted or edited and stored into the database I could scan the entire articles for images links and store the first link in a separate value in the database (this could be kind of slow though).
Also once I have those values stored and I have to display a thumbnail the only way to do so will be by showing the full image resized to the thumbnail size (that means the user has to download multiple full-size images to see the articles list with thumbnails).
Is there any better approach? (you can see the technologies used in the tags)
Create a thumbnails task that runs in the background after an article has been published.
Find image tags in the article HTML using regular expression.
Get those images and create and thumbnail that you save locally in a folder in your server.
Protect that folder/location against hotlinking.
Use those local pictures as thumbnails
Use HtmlAgilityPack as a starter to get to the images from the image host.
Use an ASP.NET handler to generate the thumbnails. That way, you won't have to store anything locally, the thumbnails images will only exist in memory, making hotlinking impossible
So I have a Windows Phone C# application in which I want to get a google weather api xml file located here: http://www.google.com/ig/api?weather=[insert zip code here] and get the current weather info. Well I want to display the image located in the xml file and I want to, based on the image, display a background image. How would I do that?
Also, I don't want to use a listbox for it because it won't let me resize the image to full screen.
You are asking rather a lot in your question, so here are some pointers rather than a complete answer.
Use Linq to XML to analyse the returned XML, using the XDocument.Parse method
Locate the images using Linq to XML, doc.Descendants("icon") will find all the icon elements, you can then iterate over them and extract the data attribute.
Create an ImageBrush for your background, setting its source to the URL of the image you require. There are numerous blog posts / SO questions that show you how to handle images in code-behind. For example:
How do you set Image.Source in Silverlight(Code behind)
This should get you started. If you get stuck on something specific, come back and ask a specific question.
i am currently facing some problem retrieving image for display on a datagridview control.
The Image data type in the database is blob.
I am using mysql as a database for retrieving the image . may i ask if it is possible to just retrieve a image data of this format and display in the gridview? or do i need to store the image in a image folder for retrieval?
I am using winforms application
Don't really think it's possible to figure out EXACT format of the image from its binary stream. The only solution I met, is storing the format in DB too, or have architectual convension to store in DB only one format type images.
Storing it in the local folder shall help you if you wish to reload it again later provided the DB isnt modified. Other wise i dont see any benefits here. Some times DB access is faster.