How To include a js file ?

  • Thread starter Thread starter Stan Sainte-Rose
  • Start date Start date
S

Stan Sainte-Rose

Hi,

With asp, I used to use the following line
<Script language="javascript" src="<%=JsFile%>"></script>

I would like to know how this can be done with asp.net ?


Thanks

Stan
 
you can still use the same with asp.net. but JsFile needs to be hardcoded
properly. Or if you want to come out of the ASP world completely,
use user controls in place of include files.

Av.
 
Hi Eliyahu,

it is not what I m really looking for..
In fact, jsfile is a variable...

So, it would be something like this..
<script id="JSFILE" language="javascript" runat="server"></script>

and I would like to change the src tag like this

JSFILE.src.value=myvariable


So I don't know if it's possible..
and if it's, how to declare the ID in the asp.vb file

Stan
 
A GenericControl in the worst case. You could also use the
RegisterClientScript method (not sure of the exact name) to "inject" this
script block in the HTML output, especially if this script is needed by a
particular "component" of your app.

Patrice
 
Sorry for not reading your mail properly.
You can set the src tag on client side with statement

document.getElementById("JSFILE").src=myvariable;

There are numerous ways of passing values from server to client side, so
setting myvariable to what you need is not a problem.

Eliyahu
 
Back
Top