-1

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...

2

2 Answers 2

0

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks..so based on shopping cart we will construct java script from server side...and it will run on client(browser)..am I right?
Yes, wordpress/php version of this function is wp_enqueue_script() see codex.wordpress.org/Function_Reference/wp_enqueue_script
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.