tags:

views:

164

answers:

5

any reference document

A: 

I assume you're trying to get a HTML page to call a function you have written in PHP/ASP/etc ("behind"). You will need to POST or GET back to the page that contains your code. This will result in a full page refresh. Alternatively you can use AJAX to POST/GET back to the function page and get the results.

taspeotis
A: 

Take a look: ClientScriptManagerclass

Rubens Farias
A: 

If you're referring to calling Javascript from the server-side code, there are a couple ways to do this, depending on your exact situation.

If you're already loading a new page, you can append the function call to the HTML. If, for example, on submitting a form you wish to make a Javascript call that points out the error messages, you would add to the end of the page:

<script type="text/javascript">pointOutErrorMessages()</script>

And have that function already declared and ready to be run.

Typically, however, the best way to go is just be using AJAX in the first place: have your Javascript make the server calls, and respond appropriately. It's a more fluid way of doing things. That, however, may be beyond the scope of your experience at this point. If you ever find yourself interested, a simple search for "javascript ajax" should get you on your way.

Matchu
+1  A: 

I think you may be referring to registering the javascript file from code:

Page.ClientScript.RegisterClientScriptInclude("myFile", "myJSFile.js");

which will output:

<script src="myJSFile.js" type="text/javascript"></script>

md5sum
A: 

Assuming you use ASP.NET, see the methods of the ClientScriptManager class. It's available within code-behind as ClientScript (which is a property of Page, which your page class derives from).

Seva Alekseyev