张雨绮袁巴元结婚:整理的关于打印不显示页眉页脚的方法

来源:百度文库 编辑:偶看新闻 时间:2024/05/05 17:56:18
整理的关于打印不显示页眉页脚的方法第一种 用脚本的方法 (http://www.cnblogs.com/yan5lang/archive/2009/12/07/1618618.html)我们可以手动删除页眉页脚,如果用户就是不想自己去修改,则可以通过下面的脚本强制进行修改: 












其中WScript.Shell(Windows Script Host Runtime Library)是一个对象,对应的文件是C:\WINDOWS\system32\wshom.ocx,Wscript.shell是服务器系统会用到的一种组件。shell 就是“壳”的意思,这个对象可以执行操作系统外壳常用的操作,比如运行程序、读写注册表、环境变量等。 在实际使用中,我发现这种方法 在aspx 使用没有效果 点击按钮清除页眉 没反应我参考别人隐藏 打印按钮的方法(http://blog.csdn.net/kittey_1999/archive/2006/09/26/1288552.aspx)第二种方法 直接用c# 调用,清空页眉页脚using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Win32;
public partial class 去掉页眉页脚 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        printnull();//隐藏ie打印的页眉和页脚
    }
    private void printnull()
    {
        RegistryKey pregkey;
        pregkey = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Internet Explorer\\PageSetup\\", true);        if (pregkey == null)
        {
            Response.Write("");
        }        else
        {
            pregkey.SetValue("footer", "");
            pregkey.SetValue("header", "");
        }
    }
}