Page.ClientScript question about Javascript

F

First Last

Hi,
Newbie question: Why use Page.ClientScript.RegisterClientScript*
when we can just make a .js file and include a reference to it in the page?
(i.e. <script src="myscript.js" type="text/javascript"></script>)

Is it because RegisterClientScript* enables us to reference ASP.NET
objects within the .js?

Thx,
Hank
 
S

Steve C. Orr [MCSD, MVP, CSM, ASP Insider]

The purpose would be to add the reference at runtime instead of design time.
If you know the details of the JavaScript file at design time it would be
best to declare it then, otherwise you'd be pretty much forced to use
RegisterClientScript.
 
B

bruce barker

it mainly for controls that spew javascript. they can not edit the page
text.

-- bruce (sqlwork.com)
 

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,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top