RSS

Tag Archives: removing header and footer while printing through code

removing header and footer while printing


First Solution

For IE & FireFox

<a href=”javascript:window.print();”>

<img title=”Print this page” src=”/images/print_icon.jpg”

border=”0″></a>

Second Solution

this is recommended code

<a href=”#”  onclick=”window.print()” onmouseup=”document.getElementById(‘header’).style.display=’None’;document.getElementById(‘footer’).style.display=’None'”> Print </a>

Third Solution

removing header and footer while printing the page through coding?

With C# Language

I have the code for making the header and footer to be removed dynamically while printing

public void IESetupFooter()

{

string strKey = “Software\\Microsoft\\Internet Explorer\\PageSetup”;

bool bolWritable = true;

string strName = “footer”;

object oValue = “”;

RegistryKey oKey = Registry.CurrentUser.OpenSubKey(strKey, bolWritable);

Console.Write(strKey);

oKey.SetValue(strName, oValue);

oKey.Close();

}

public void IESetupHeader()

{

string strKey1 = “Software\\Microsoft\\Internet Explorer\\PageSetup”;

bool bolWritable1 = true;

string strName = “header”;

object oValue1 = “”;

RegistryKey oKey = Registry.CurrentUser.OpenSubKey(strKey1, bolWritable1);

Console.Write(strKey1);

oKey.SetValue(strName, oValue1);

oKey.Close();

}

With Vb.Net

Public Sub IESetupFooter()
	Dim strKey As String = "Software\Microsoft\Internet Explorer\PageSetup"
	Dim bolWritable As Boolean = True
	Dim strName As String = "footer"
	Dim oValue As Object = ""
	Dim oKey As RegistryKey = Registry.CurrentUser.OpenSubKey(strKey, bolWritable)
	Console.Write(strKey)
	oKey.SetValue(strName, oValue)
	oKey.Close()
End Sub
Public Sub IESetupHeader()
	Dim strKey1 As String = "Software\Microsoft\Internet Explorer\PageSetup"
	Dim bolWritable1 As Boolean = True
	Dim strName As String = "header"
	Dim oValue1 As Object = ""
	Dim oKey As RegistryKey = Registry.CurrentUser.OpenSubKey(strKey1, bolWritable1)
	Console.Write(strKey1)
	oKey.SetValue(strName, oValue1)
	oKey.Close()
End Sub

Directly Remove from Browser

Internet Explorer 7

 

 

Firefox

 

 

 

 
7 Comments

Posted by on May 31, 2011 in ASP Dot Net C#, Java Script, Vb.Net

 

Tags: , , ,