Click here to Skip to main content
15,894,539 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have done code for a security pass using following code,it full filling my requirements, but now problem is that when i press cntrl+p print dialogue is appeared ,but it print just name etc,no background image is display?
C#
protected void EmpSC_Click(object sender, EventArgs e)
     {
         EmployeeSpDataSet dataset = new EmployeeSpDataSet();
         StringBuilder sb = new StringBuilder();
         var AllEmp = _service.GetAllEmployeeDuty().OrderByDescending(x => x.EndDate).GroupBy(x => x.Employee_Id).Select(x => x.First()).Take(3).ToList();
         if (AllEmp != null)
         {
             for (int i = 1; i <= 3; i++)
             {
                 var empsp = AllEmp.FirstOrDefault();
                 var emp = _service.GetAllEmployee().Where(x => x.Id == empsp.Employee_Id).FirstOrDefault();
                 dataset.EmployeeScpass.Rows.Add(emp.Id,
                     emp.Name,
                     emp.Cnic,
                     empsp.ToSectorName,
                     emp.ImgBody, ""
                     );
                 sb.Append("<table style=\"height:324px; width:1008px\">");
                 sb.Append("<tr>");
                 sb.Append("<td>");
                 sb.Append("<table style=\"height:323px; width:504px; background-image:removed(../Images/PassFront.jpg)\">");
                 sb.AppendFormat("<td><img src=\"EmpPicture.ashx?id={0}\" style=\"height:200px; width:200px; margin-top:41px; margin-left:17px;\" /></td>", emp.Id);
                 sb.Append("<td ><table style=\"height:20px;margin:30px;\">");
                 sb.AppendFormat("<tr style=\"height:116px;margin:30px;\"><td> </td><td>{0}</td></tr>", emp.Name);
                 sb.AppendFormat("<tr style=\"height:26px;\"><td> </td><td>{0}</td></tr>", emp.Cnic);
                 sb.AppendFormat("<tr style=\"height:95px;\"><td> </td><td>{0}</td></tr>", empsp.ToSectorName);
                 sb.AppendFormat("<tr style=\"height:13px;\"><td> </td><td>{0}</td></tr>", emp.Id);
                 sb.Append("</table></td></tr><tr><td></td><td></td></tr></table></td>");
                 sb.Append("<td>");
                 sb.Append("<table style=\"height:323px; width:504px; background-image:removed(../Images/PassBack.jpg)\">");
                 sb.Append("</table></td></tr></table><br/>");
                 AllEmp.Remove(empsp);
             }

             spcards.InnerHtml = sb.ToString();

         }
Posted
Updated 19-Jun-15 19:06pm
v2
Comments
Sergey Alexandrovich Kryukov 20-Jun-15 1:12am    
Not clear. If a background is not shown in print, this is the usual behavior...
—SA
Sajid227 20-Jun-15 1:15am    
then how to make it function properly?
Sergey Alexandrovich Kryukov 20-Jun-15 2:11am    
This is not related to your code at all. Please see my answer.
—SA

1 solution

Not printing background colors and images is just on of the browsers printing options, typically of "Page Setup".

You cannot do anything about it, because this is not related to your page code. And you don't need to do anything about it. It's just the user's choice how to do printing, what options to choose, what should be done by default, and so on.

—SA
 
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