TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
faesel
NA
4
0
Retrieve image from DB and displaying along with components.
Nov 22 2007 10:29 AM
Hi everyone,
Currently i have a aspx page called game.aspx, which contains various components and a button called 'show image' when i press this button i want the image to be retrieved from the sql database and show on game.aspx
At the moment I am using Response.BinaryWrite to display the image to a aspx page called image.aspx, code shown below:
namespace WebApplication.MemberPages
{
public partial class Image : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public void GenerateImage()
{
Byte[] content = game.RetrieveImageBinary(); //Gets binary data from the database
System.Web.HttpContext.Current.Response.BinaryWrite(content);
System.Web.HttpContext.Current.Response.ContentType = "image/jpg";
}
}
In game.aspx i have a imagebox where the source is 'image.aspx'
Code: <asp:Image ID="Image2" runat="server" ImageUrl="Image.aspx" />
This displays the image correctly, although when doing so all other components that where on the game.aspx page have all disappeared!!
My question is am i doing anything wrong? Is Response.BinaryWrite the best solution to the problem? (i am willing to take different approaches).
Due to the program being a web application I don’t have access to a picturebox(would have made life a lot easier) and i am not to keen on making a temporary file.
Thanks
Faesel Saeed
Reply
Answers (
1
)
uploading pics into database and retrieving from the database when required
Dynamic generation of controls