Custom Server Controls and javascript

M

Mantorok

Hi all

I have some client-script to accompany some of my custom server controls, at
the moment these functions are added at run-time.

Is it feasible to put all these functions into one .js file and have the
controls include it? If so, how can I include the file?

Thanks
Kev
 
T

Teemu Keiski

Hi,

it is recommended to put them into js file since then referencing it with a
script block, helps browser to cache ths js file (no need to download
scripts every time). The way to do it with
Page.ClientScript.RegisterClientScriptResource method so that the js file is
embedded on the assembly as a resource file (note: it must be separate class
library, cannot be in App_Code)

References:

http://msdn2.microsoft.com/en-us/li...riptmanager.registerclientscriptresource.aspx

Embedding Resources in ASP.NET 2.0 Assemblies
http://aspalliance.com/726
 

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,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top