How can I call a javascript function, that is in the aspx page, from the Page_Load method, in the code-behind?
Shide's solution works. The problem is if you want to run your piece of code only on postback, for example. The solution I found was to use a "cookie": I verify if cookie x exists, if it doesn't I run the javascript code and set the cookie. When you hit refresh, the cookie will be found so the piece of code won't run.
function pageLoad() {
if(localStorage.getItem("cookie") === null) {
localStorage.setItem("cookie", true);
//run code
}
}
Any code you need to run every single time just leave it out of the if statement.