<asp:LinkButton ID="lbnPrint" runat="server" class="msLinkButton" OnClientClick="CallPrint();"
TabIndex="9" Text="Print"></asp:LinkButton>
function CallPrint()
{
var lbnCreatereport = document.getElementById('ctl00_ContentPlaceHolder_lbnCreatereport');
if (lbnCreatereport != null)
{
lbnCreatereport.style.display = 'none';
}
var lbnSave = document.getElementById('ctl00_ContentPlaceHolder_lbnsave');
if (lbnSave != null)
{
lbnSave.style.display = 'none';
}
var lbnCancel = document.getElementById('ctl00_ContentPlaceHolder_lbncancel');
if (lbnCancel != null)
{
lbnCancel.style.display = 'none';
}
var lbnSubmit = document.getElementById('ctl00_ContentPlaceHolder_lbnsubmit');
if (lbnSubmit != null)
{
lbnSubmit.style.display = 'none';
}
var lbnPrint = document.getElementById('ctl00_ContentPlaceHolder_lbnprint');
if (lbnPrint != null)
{
lbnPrint.style.display = 'none';
}
var txtSDName = document.getElementById('ctl00_ContentPlaceHolder_txtSDName');
if (txtSDName != null)
{
txtSDName.style.border = 'none';
txtSDName.disabled=false ;
txtSDName .readOnly=true;
}
var display_setting = "'', '', 'left=0,top=0,width=800,height=600,toolbar=0,scrollbars=1,status=0,resizable'";
var content_innerhtml = document.getElementById("printme").innerHTML;
var document_print = window.open("", "", display_setting);
document_print.document.open();
document_print.document.write(content_innerhtml);
document_print.document.write('</body></html>');
document_print.print();
document_print.document.close();
return false;
}
Hi, I tried on print linkbutton, I wrote the code using javascript for Print LinkButton. When clicking on the Print Linkbutton it's open the new window , The problem here is after opening the new window , the Main page is refreshing and lose data in main page,and also in new window open a message box , in that Print and cancel Buttons . when click on the cancel button and it refreshing the main page also.
I think , we wrote the javascript for print popup, why refreshing the main page when opening the new window and cancel button in new window.
Please any one help me