I want to call a javascript function when the gridview loads. Im calling it like this,
<asp:GridView ID="GridView4" runat="server" OnLoad="javascript:AddTHEAD('<%= GridView4.ClientID %>')">
</asp:GridView>
and here is the javascript function
<script type="text/javascript">
function AddTHEAD(tableName) {
window.open(document.location.href+'&mode=print','_blank');
var table = document.getElementById(tableName);
if (table != null) {
var head = document.createElement("THEAD");
head.style.display = "table-header-group";
head.appendChild(table.rows[0]);
table.insertBefore(head, table.childNodes[0]);
}
}
</script>
But im getting compilation errors on calling javasccript function like this. How to call javascript function on the OnLoad event of GridView? What i want to do is basically print gridview header on each page, but i couldn't figure out how. Please help!