Sumit Kumar Singh India wrote:
When i put in body then only this happened. When i put this javascript code in head then its not called automatically but the c# function not working in head.
That's why I asked. This statement itself contains the answer to the question.
This behavior is correct and is the part of HTML standard: if you want some script to elaborate when some function is called, put it in the
<head>
element. What you put a script in
<body>
, it is executed automatically. A script in the
<head>
is like a library, a script in the
<body>
is like entry point. This is something important to know if your do scripting.
—SA