Click here to Skip to main content
15,890,336 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Syntax error: Missing operand after '12' operator. Pin
fjdiewornncalwe10-May-10 8:27
professionalfjdiewornncalwe10-May-10 8:27 
Questionhtml looks different in Firefox Pin
Tridip Bhattacharjee10-May-10 2:41
professionalTridip Bhattacharjee10-May-10 2:41 
AnswerRe: html looks different in Firefox Pin
Brij10-May-10 2:51
mentorBrij10-May-10 2:51 
AnswerRe: html looks different in Firefox Pin
Abhijit Jana10-May-10 3:06
professionalAbhijit Jana10-May-10 3:06 
AnswerRe: html looks different in Firefox Pin
Peace ON10-May-10 3:52
Peace ON10-May-10 3:52 
GeneralRe: html looks different in Firefox Pin
Tridip Bhattacharjee10-May-10 20:17
professionalTridip Bhattacharjee10-May-10 20:17 
Questionhow to do paging with multiple active result sets Pin
happies10-May-10 2:07
happies10-May-10 2:07 
Questionhow to display nopicture image in a image control when there is no image in a database using asp.net with c# Pin
developerit10-May-10 1:54
developerit10-May-10 1:54 
hi , iam using asp.net with c#

iam displaying images using Handler.ashx but when there is no image present in a database i want to display nopic.jpg picture

can you correct my code which helps me

using System;
using System.Web;

using System.IO;
using System.Data;
using System.Data.SqlClient;



public class left1old : IHttpHandler {
    
    public void ProcessRequest (HttpContext context)
    {

        int branchid = 0;

        if (context.Session["branchid"] != null)
            //if (context.Request.QueryString["Shop"] != null)

            branchid = Convert.ToInt32(context.Session["branchid"]);
        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(int branchid)
    {
        SqlConnection con = new SqlConnection(" Data Source=.; Initial Catalog=SafaView;User ID=sa;Password=nsg_ss_0103;");
        string sql = "SELECT imgleft1old 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 System.IO.Stream("~/images/NoPic.jpg");
        }
        finally
        {
            con.Close();
        }
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}


in page load
=============

protected void Page_Load(object sender, EventArgs e)
    {int i=0;
       i= Convert.ToInt32(Session["branchid"]);
        if (IsPostBack == false)
        {
            Image1.ImageUrl = "left1.ashx?BranchId=" + i;
            Image2.ImageUrl = "left1old.ashx?BranchId=" + i;
                    
        
        }


can you correct my code which helps me
AnswerRe: how to display nopicture image in a image control when there is no image in a database using asp.net with c# Pin
Brij10-May-10 2:37
mentorBrij10-May-10 2:37 
AnswerRe: how to display nopicture image in a image control when there is no image in a database using asp.net with c# Pin
Tej Aj10-May-10 2:58
Tej Aj10-May-10 2:58 
AnswerRe: how to display nopicture image in a image control when there is no image in a database using asp.net with c# Pin
Martin Jarvis10-May-10 12:49
Martin Jarvis10-May-10 12:49 
QuestionMake webpage sleep for a while Pin
seemadas10-May-10 1:04
seemadas10-May-10 1:04 
AnswerRe: Make webpage sleep for a while Pin
Abhijit Jana10-May-10 1:27
professionalAbhijit Jana10-May-10 1:27 
GeneralRe: Make webpage sleep for a while Pin
seemadas10-May-10 1:34
seemadas10-May-10 1:34 
AnswerRe: Make webpage sleep for a while Pin
Brij10-May-10 2:48
mentorBrij10-May-10 2:48 
QuestionInsert Skips When use in a Loop Pin
yogesh_kumar_agarwal10-May-10 0:20
yogesh_kumar_agarwal10-May-10 0:20 
AnswerRe: Insert Skips When use in a Loop Pin
Michel Godfroid10-May-10 0:45
Michel Godfroid10-May-10 0:45 
GeneralRe: Insert Skips When use in a Loop Pin
yogesh_kumar_agarwal10-May-10 1:32
yogesh_kumar_agarwal10-May-10 1:32 
GeneralRe: Insert Skips When use in a Loop Pin
Michel Godfroid10-May-10 1:44
Michel Godfroid10-May-10 1:44 
AnswerRe: Insert Skips When use in a Loop Pin
Abhijit Jana10-May-10 0:59
professionalAbhijit Jana10-May-10 0:59 
GeneralRe: Insert Skips When use in a Loop Pin
yogesh_kumar_agarwal10-May-10 1:36
yogesh_kumar_agarwal10-May-10 1:36 
GeneralRe: Insert Skips When use in a Loop Pin
Abhijit Jana10-May-10 1:42
professionalAbhijit Jana10-May-10 1:42 
GeneralRe: Insert Skips When use in a Loop Pin
Michel Godfroid10-May-10 2:01
Michel Godfroid10-May-10 2:01 
AnswerRe: Insert Skips When use in a Loop Pin
Martin Jarvis10-May-10 12:34
Martin Jarvis10-May-10 12:34 
QuestionPermission Issue Pin
Hema Bairavan10-May-10 0:15
Hema Bairavan10-May-10 0:15 

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.