Sunday, 15 February 2015

Why would there be a need to call a JavaScript function from code behind? -


I'm just looking at the Javascript function to call behind the code online, for example I have given you a RegisterStartupScript method Click on the event you saw, but why would you like to do it or instead of just waving the OnClientClick event? Do I ever need to call the JavaScript function behind the code?

Register Startupscripts is one of several options for an infinite number of scenarios. In the end, you can do anything you can do with RegisterStartupScript, another way can be done, I used to consider it on a feature, I now avoid it, separating the concerns and such high levels of "enlightenment" I use it.

Mainly where I see Register Startupscript still in use, without the end user know anything about them. See,, etc. They require all javascript but for obvious reasons you do not expect to include or register your client-side script.

Random scenario:

  if (User.Identity.Name == "Frank") RegisterStartupScript (This, GetType (), "Frank", "Alert (" Hey Frank, you have to pay me! ");  

In the alternative scenario, server-side sets a hidden field.

    

No comments:

Post a Comment