RegisterClientScriptBlock
and RegisterStartupScript
do not "call" code or functions, they simply add code to the page; RegisterClientScriptBlock
adds script to the top of the page—so it might not see all the html because it's not loaded; RegisterStartupScript
adds script to the bottom of the page—so all the html is available to it.
If you want to scroll down when the page loads, take it out of the function:
// this will run the *first time* the page loads.
window.scrollTo(0, document.body.scrollHeight); // no function.
If you want to call it from a click, use a function:
function goToBottom() {
window.scrollTo(0, document.body.scrollHeight);
}
Calling code behind from javascript is another issue. It has been asked before. Search the site or start another question.