if you don't want to use JS functions then Use below process:
Process 1:
#region PrintLogicNew
string fileName = System.IO.Path.GetFileName(Request.Path).Substring(0, System.IO.Path.GetFileName(Request.Path).Length - 5);
Utilities.Common obj_Common = new Utilities.Common();
hdfPrintCacheId.Value = fileName + Session.SessionID + "Print";
Cache.Insert(hdfPrintCacheId.Value, dvPrint, null, DateTime.MaxValue, TimeSpan.FromMinutes(Convert.ToDouble(ConfigurationSettings.AppSettings["CacheExpiryTime"])));
#endregion
Process 2:
At HTML Page
<asp:hiddenfield id="hdfPrintCacheId" runat="server" xmlns:asp="#unknown" />
<a href="#" önclick="JavaScript:openPrintWindowWithQueryString('<%=hdfPrintCacheId.Value %>');">
<img src="../Images/print.gif" style="border: none" /></a>
Above process will help you. :-D
==================================================================
If you want to use a JS function, then
function Clickheretoprint() {
var disp_setting = "toolbar=yes,location=no,directories=yes,menubar=yes,";
disp_setting += "scrollbars=yes,width=650, height=600, left=100, top=25";
var content_vlue = document.getElementById("dvNestedGridPrint").innerHTML;
var docprint = window.open("", "", disp_setting);
docprint.document.open();
docprint.document.write('<html><head><title>Approved BOM</title>');
docprint.document.write('</head><body onLoad="self.print()"><center>');
docprint.document.write(content_vlue);
docprint.document.write('</center></body></html>');
docprint.document.close();
docprint.focus();
}