Click here to Skip to main content
15,899,679 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Log In Control with Ajax Pin
kushMuchaal11-May-10 1:33
kushMuchaal11-May-10 1:33 
GeneralRe: Log In Control with Ajax Pin
Not Active11-May-10 1:37
mentorNot Active11-May-10 1:37 
GeneralRe: Log In Control with Ajax Pin
kushMuchaal11-May-10 1:45
kushMuchaal11-May-10 1:45 
GeneralRe: Log In Control with Ajax Pin
Not Active11-May-10 2:28
mentorNot Active11-May-10 2:28 
AnswerRe: Log In Control with Ajax Pin
saini arun11-May-10 1:46
saini arun11-May-10 1:46 
GeneralRe: Log In Control with Ajax Pin
kushMuchaal11-May-10 1:49
kushMuchaal11-May-10 1:49 
GeneralRe: Log In Control with Ajax Pin
Not Active11-May-10 2:34
mentorNot Active11-May-10 2:34 
Questionhow to display an image from folder when there is no image in database Pin
developerit10-May-10 22:10
developerit10-May-10 22:10 
hi iam using asp.net with c#

i want to display an default image from my website folder when there is no image in database , can you correct my code

<%@ WebHandler Language="C#" Class="left1" %>

using System;
using System.IO;
using System.Data;
using System.Data.SqlClient;
using System.Web.UI;


using System.Web;

public class left1 : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        string  branchid = "";
        
        if(context.Session["branchid"]!=null)
        

            branchid= context.Session["branchid"].ToString();
        else
            throw new ArgumentException("No parameter specified");

        context.Response.ContentType = "image/jpeg";
        Stream strm = ShowImage(branchid);
        byte[] buffer = new byte[4096];
        int byteSeq = strm.Read(buffer, 0, 4096);

        while (byteSeq > 0)
        {
            context.Response.OutputStream.Write(buffer, 0, byteSeq);
            byteSeq = strm.Read(buffer, 0, 4096);
        }
            }
public Stream ShowImage(string  branchid)
    {
        SqlConnection con = new SqlConnection(" Data Source=.; Initial Catalog=SafaView;User ID=sa;Password=nsg_ss_0103;");
        string sql = "SELECT imgleft1 FROM tblImages WHERE BranchId = @BranchId";
        SqlCommand cmd = new SqlCommand(sql, con);
        cmd.CommandType = CommandType.Text;
        cmd.Parameters.AddWithValue("@BranchId", branchid);
        con.Open();
        object img = cmd.ExecuteScalar();
                try
        {
            return new MemoryStream((byte[])img);
        }
        catch
        {
            return null;
        }
        finally
        {
            con.Close();
        }
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }
}


in page load
=========
string id = "";
protected void Page_Load(object sender, EventArgs e)
    {
      id= Session["branchid"].ToString();
        if (IsPostBack == false)
        {
            Image1.ImageUrl = "left1.ashx?BranchId="+id;
            Image2.ImageUrl = "left1old.ashx?BranchId="+id;
                    
        
           }


i want to display a default image when there is no image in database

can you correct my code
AnswerRe: how to display an image from folder when there is no image in database Pin
Dinesh Mani10-May-10 23:01
Dinesh Mani10-May-10 23:01 
QuestionHow to Hide A GridView Column in a Visual Web Developer project Pin
grafiksinc10-May-10 21:16
grafiksinc10-May-10 21:16 
AnswerRe: How to Hide A GridView Column in a Visual Web Developer project Pin
Pranay Rana10-May-10 23:04
professionalPranay Rana10-May-10 23:04 
GeneralRe: How to Hide A GridView Column in a Visual Web Developer project Pin
grafiksinc11-May-10 1:21
grafiksinc11-May-10 1:21 
AnswerRe: How to Hide A GridView Column in a Visual Web Developer project Pin
Dinesh Mani10-May-10 23:07
Dinesh Mani10-May-10 23:07 
GeneralRe: How to Hide A GridView Column in a Visual Web Developer project Pin
grafiksinc11-May-10 1:23
grafiksinc11-May-10 1:23 
AnswerRe: How to Hide A GridView Column in a Visual Web Developer project Pin
Dinesh Mani11-May-10 1:59
Dinesh Mani11-May-10 1:59 
AnswerRe: How to Hide A GridView Column in a Visual Web Developer project Pin
HimansuSekharPati12-May-10 2:40
HimansuSekharPati12-May-10 2:40 
AnswerRe: How to Hide A GridView Column in a Visual Web Developer project Pin
grafiksinc16-May-10 13:11
grafiksinc16-May-10 13:11 
Questionopen source Pin
mylogics10-May-10 21:00
professionalmylogics10-May-10 21:00 
AnswerRe: open source Pin
Michel Godfroid10-May-10 22:40
Michel Godfroid10-May-10 22:40 
QuestionPrint in report wizard Pin
4anusha410-May-10 19:34
4anusha410-May-10 19:34 
QuestionWebsite project type to Web application project type NO ONE-CLICK SOLUTION POSSIBLE [modified] Pin
fjparisIII10-May-10 18:12
fjparisIII10-May-10 18:12 
AnswerRe: Website project type to Web application project type Pin
Abhijit Jana10-May-10 18:33
professionalAbhijit Jana10-May-10 18:33 
GeneralRe: Website project type to Web application project type Pin
fjparisIII11-May-10 8:40
fjparisIII11-May-10 8:40 
GeneralRe: Website project type to Web application project type Pin
fjparisIII11-May-10 13:25
fjparisIII11-May-10 13:25 
Questioncan't find html text formatting for my CMS , how can i find it ???? Pin
Med7at10-May-10 16:32
Med7at10-May-10 16:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.