Home All Groups Group Topic Archive Search About

Custom Server Controls and javascript

Author
29 Aug 2006 8:33 AM
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

Author
30 Aug 2006 7:13 PM
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/library/system.web.ui.clientscriptmanager.registerclientscriptresource.aspx

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


--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke



Show quoteHide quote
"Mantorok" <n***@none.com> wrote in message
news:ed0u15$c3l$1@newsfeed.th.ifl.net...
> 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
>
Author
1 Sep 2006 3:24 PM
Mantorok
Thanks, I got it working with that method.

Cheers
Kev

Show quoteHide quote
"Teemu Keiski" <jot***@aspalliance.com> wrote in message
news:uXCnvhGzGHA.772@TK2MSFTNGP05.phx.gbl...
> 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/library/system.web.ui.clientscriptmanager.registerclientscriptresource.aspx
>
> Embedding Resources in ASP.NET 2.0 Assemblies
> http://aspalliance.com/726
>
>
> --
> Teemu Keiski
> ASP.NET MVP, AspInsider
> Finland, EU
> http://blogs.aspadvice.com/joteke
>
>
>
> "Mantorok" <n***@none.com> wrote in message
> news:ed0u15$c3l$1@newsfeed.th.ifl.net...
>> 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
>>
>
>