How Do I Show images on Asp.Net Website with Linq Query?
i can add images without any problem to my website.with my below code..i am using linq and asp.net with c#....
ImageDatabaseDataContext imdb = new ImageDatabaseDataContext();
Dosyalar ds;
Katilimci kt;
protected void btnEkle_Click(object sender, EventArgs e)
{
if (FileUpload1.FileContent != null)
{
string dosyaAdi = Guid.NewGuid().ToString();
byte[] icerik = FileUpload1.FileBytes;
string dosyaTipi = FileUpload1.PostedFile.ContentType;
try
{
ds = new Dosyalar();
kt = new Katilimci();
kt.AdSoyad = txtAdSoyad.Text;
kt.BolgeMudurlugu = txtBolgeMudurlugu.Text;
k开发者_JAVA百科t.Gorevi = txtGorev.Text;
kt.NoktaAd = txtNoktaAd.Text;
kt.NoktaTuru = txtNoktaTuru.Text;
imdb.Katilimcis.InsertOnSubmit(kt);
imdb.SubmitChanges();
int idsi = kt.KID;
ds.DosyaAD = dosyaAdi;
ds.DosyaICERIK = icerik;
ds.DosyaTIP = dosyaTipi;
ds.KID = idsi;
imdb.Dosyalars.InsertOnSubmit(ds);
imdb.SubmitChanges();
}
catch (Exception ex)
{
lblHataci.Text = ex.Message;
}
}
}
here is my question..How do i show my images that i was saving on sql server?on asp.Net website with linq queries?
Thanks for your answer...
you can use the solution to this question as long as you get the contents of the image from the database. it doesnt depend on any linq-to-sql.
Dynamically Rendering asp:Image from BLOB entry in ASP.NET
`public class ImageHandler : IHttpHandler {
public void ProcessRequest(HttpContext context)
{
using(Image image = GetImage(context.Request.QueryString["ID"]))
{
context.Response.ContentType = "image/jpeg";
image.Save(context.Response.OutputStream, ImageFormat.Jpeg);
}
}
public bool IsReusable
{
get
{
return true;
}
}
}`
this code solves my question thank you.
精彩评论