Javascript Code In First ContentPlaceHolder :-
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script type="text/javascript" >
function PrintElem(elem) {
alert(elem);
Popup($(elem).html());
}
function Popup(data) {
var mywindow = window.open('', 'Loan Approve Details', 'height=400,width=600');
mywindow.document.write('<html><head><title>Loan Inquiry Details</title>');
/*optional stylesheet*/ //mywindow.document.write('<link rel="stylesheet" href="main.css" type="text/css" />');
mywindow.document.write('</head><body >');
mywindow.document.write(data);
mywindow.document.write('</body></html>');
mywindow.print();
mywindow.close();
return true;
}
</script>
</asp:Content>
Source Code in second ContentPlaceHolder :-
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div id="mydiv">
<table>
//here is lots of textbox and other controls
<asp:Button ID="btnPrint" runat="server" Text="Print" OnClientClick="PrintElem('#mydiv')"
CausesValidation="False" />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button"
CausesValidation="False" />
</table>
</div>
</asp:Content>
Code Behind :-
protected void Button1_Click(object sender, EventArgs e)
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "myscript", "PrintElem('#mydiv')",true);
}
Explanation :- Here my problem is that when I call PrintElem(elem) function from source code then it works properly but when I call PrintElem(elem) function from code behind then I am not getting any value of div in $(elem).html() even I am getting same id value in alert(elem) so please help me to solve this problem.And I actually want to print all contents of div tag after execution of some code in code behind.so I am trying something like this.