Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi,

i have requirement in that one aspx page with many input control in that image box also. if user upload maximum of 4 images with less than 1 mb, that can be shown every time user login into his account with other details also. if i load that four images browser get hangout,it crashed and closed automatically. pls give some suggestion or solution to recover this performance kind of issues from browser hangout. what will be best ways to do this requirement.

here is my code for showing that images in image control url :

C#
string strQuery = "select Name, Data from tblFiles where userid=@id";
        SqlCommand cmd = new SqlCommand(strQuery);
        cmd.Parameters.Add("@id", SqlDbType.Int).Value
        = Convert.ToInt32 (5248);
        DataTable dt = GetData(cmd);
if (dt != null)
        {
	if(dt.Rows[0]["Data"] !=DBNull.Value)
	{
	byte[] bytes = (byte[])dt.Rows[0]["Data"];
        string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
        Image1.ImageUrl = "data:image/png;base64," + base64String;	
}
if(dt.Rows[1]["Data"] !=DBNull.Value)
	{
	byte[] bytes = (byte[])dt.Rows[2]["Data"];
        string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
        Image2.ImageUrl = "data:image/png;base64," + base64String;	
}
if(dt.Rows[2]["Data"] !=DBNull.Value)
	{
	byte[] bytes = (byte[])dt.Rows[2]["Data"];
        string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
        Image3.ImageUrl = "data:image/png;base64," + base64String;	
}
if(dt.Rows[3]["Data"] !=DBNull.Value)
	{
	byte[] bytes = (byte[])dt.Rows[3]["Data"];
        string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
        Image4.ImageUrl = "data:image/png;base64," + base64String;	
}
}
Posted

1 solution

Hey

Why don't you save it on an authorized directory and use it's URL instead of having them converted to base64 back and forth? Base64 is recommended on short images, not the bigger ones.

Hope this helps!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900