Frage

I am new to asp.net. I know javascript is client-side scripting language. Then what is a benefit to call it from server side using RegisterClientScriptBlock method.

Please explain...

War es hilfreich?

Lösung

Some server side modules in a CMS or a shopping cart requires client side javascript. A good example would be an gallery plugin / module that is installed via the server side admin area bit it requires client side JS code to work. These plugins use functions like RegisterClientScriptBlock to add the required JS libraries to the template.

Andere Tipps

Javascript is not called from server side, it's always called from the client in the scenario you described. Using RegisterClientScriptBlock you just set the script in the webpage just as using the script tag in html(you may want to create a dynamic javascript and this could be a reason to register the script from server side); you are not calling the script from server - the script will be executed on the client.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top