way to inject javascript?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to inject a large javascript function into an asp.net page, in
1.1 and 2.0?
 
Hi,
Is there a way to inject a large javascript function into an asp.net page, in
1.1 and 2.0?

The best way remains using external JavaScript files, and including the
file using a <script> tag:

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

The script files can also be embedded in a DLL, using an embedded
resource and the webresource.axd handler.

http://www.nikhilk.net/WebResourceAttribute.aspx

If the script needs to be dynamically modified, then you have to use the
RegisterClientScriptBlock method (in the Page class for ASP.NET 1.1, and
in the ClientScriptManager for ASP.NET 2.0), but it is to be avoided
especially for big functions, because then it won't be cached, but sent
to the client on every request.

HTH,
Laurent
 
Back
Top