ASP.NET - image display - Asked By msakt on 24-May-12 06:36 AM


 fupBill.SaveAs(Server.MapPath(@"Upload\Bill\" + fupBill.FileName));

        ViewState["FileName"] = fupBill.FileName;
       
        imgBill.ImageUrl =

after upload i display in above image  how......
kalpana aparnathi replied to msakt on 24-May-12 06:58 AM
hi,

Try below code:

protected void UploadButton_Click(object sender, EventArgs e)
{
    string savePath = "\\uploads\\";
    if (FileUpload1.HasFile)
      {
        string fileName = FileUpload1.FileName;
        savePath += fileName;
        FileUpload1.SaveAs(Server.MapPath(savePath));
      Bitmap bitmap = null;
        try
          {
            bitmap = new Bitmap(FileUpload1.FileContent);
        }
          catch (System.Exception generatedExceptionName)
          {
        }
      if (bitmap == null)
          {
            UploadStatusLabel.Visible = true;
            UploadStatusLabel.Text = "Your file is not an image";
            Image1.Visible = false;
            ListBox1.Visible = false;
        }
     else
        {
            UploadStatusLabel.Visible = false;
            Image1.ImageUrl = savePath;
            Image1.Visible = true;
            ListBox1.Items.Clear();
            ListBox1.Visible = true;
            findBarcodes(Server.MapPath(savePath));
            if (ListBox1.Items.Count == 0) {
                ListBox1.Items.Add("No barcodes found");
            }

        }
    }
 else {
       UploadStatusLabel.Text = "You did not specify a file to upload.";
    }
}


Regards,
Somesh Yadav replied to msakt on 24-May-12 07:15 AM

try this way

<asp:TemplateField HeaderText="Reporting Status">
         
<ItemTemplate>
                        <asp:Image ID="img1" runat="server"
                            ImageUrl='
<%#Eval("path") %>'></asp:Image>
         
</ItemTemplate>
                   

 
</asp:TemplateField>
or

Try this code

http://www.aspsnippets.com/Articles/Display-images-from-SQL-Server-Database-in-ASP.Net-GridView-control.aspx
dipa ahuja replied to msakt on 24-May-12 08:35 AM
<asp:ImageButton ID="ImageButton1" runat="server"
PostBackUrl='<%# Eval("purl","display.aspx?purl={0}") %>'
ImageUrl='<%# Eval("purl","Images/{0}") %>'/>
 
display.aspx:
 
protected void Page_Load(object sender, EventArgs e)
{
  string url = Request.QueryString["purl"].ToString();
 
  Image Image1 = new Image();
  Image1.ImageUrl = "~/Images/" + url;
}