如何使用C#或Jquery打印子页面 [英] How Do I Print A Child Page Using C# Or Jquery

查看:71
本文介绍了如何使用C#或Jquery打印子页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用以下代码完成了安全通行证的代码,它完全满足我的要求,但现在的问题是,当我按cntrl + p打印对话框出现,但它只打印名称等,没有显示背景图像?

  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)。选择(x = > x.First ())。取( 3 )。ToList();
if (AllEmp!= null
{
for int i = 1 ; i < = 3 ; i ++)
{
var empsp = AllEmp.FirstOrDefault();
var emp = _service.GetAllEmployee()。​​其中​​(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:移除(../图像/ 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;余量: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>< /表>< / TD>中);
sb.Append( < td>);
sb.Append( < table style = \height:323px; width:504px; background -Image:移除(../图像/ PassBack.jpg)\ > 中);
sb.Append( < / table>< / td>< / tr>< /表><峰; br />中);
AllEmp.Remove(empsp);
}

spcards.InnerHtml = sb.ToString();

}

解决方案

打印浏览器时不打印背景颜色和图像选项,通常是页面设置。



你无能为力,因为这与你的页面代码无关。而且你不需要做任何事情。这只是用户的选择如何进行打印,选择哪些选项,默认应该做什么等等。



-SA

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?

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();

         }

解决方案

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


这篇关于如何使用C#或Jquery打印子页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆