Reputation: 897
I have database with Image field, and asp:FileUpload
on the page. Method for save image is
protected void btnUploadImage_Click(object sender, EventArgs e)
{
Stream str = uplReportImage.FileContent;
//записать в файл
ViewHolder.CurrentTemplate.HeaderLogo = System.Drawing.Image.FromStream(str);
}
So, in my ViewHolder
I have System.Drawing.Image
field. How can I set it to asp:Image
control?
Upvotes: 0
Views: 703
Reputation: 156978
I would write a HttpHandler that fetched the image from a specific url. You can use the url in your pages, and fetch it in the http handler.
This has advantages when browsers cache images, and you can reuse the image easily on different pages.
Upvotes: 1
Reputation: 11
The control has an ImageUrl property which can be set to a unique GUID to a server-side handler, which can parse the GUID and dynamically write the contents of System.Drawing.Image as Response.BinaryWrite by setting an appropriate mime type.
Upvotes: 1