Calling a javascript function from Page_Load in code-behind

后端 未结 8 1218
广开言路
广开言路 2021-01-25 03:49

How can I call a javascript function, that is in the aspx page, from the Page_Load method, in the code-behind?

8条回答
  •  臣服心动
    2021-01-25 04:16

    If you just want to call a JavaScript function ( and do not need to pass something from code-behind, then use this...)

    • document.onload = function () { your-function(); };

    • window.onload = function () { your-function(); };

    • document.readyState = function () { your-function(); }

      ... depending on your specific requirements.

    Hope this makes sense to you & answers your question.

提交回复
热议问题