way to inject javascript?

G

Guest

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

Laurent Bugnion

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top