|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Custom Server Controls and javascriptHi 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 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 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 > 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 >> > >
objectdataSource case sensitive with parameters??
Need some advice on a GridView control. Exposing an event handler as a control property Don't understand state in WebControls class Add control to TreeView (ASP.NET 2.0) Page CallBack ICallbackEventHandler Issue getting value from dynamically creating datagrid boundcolumn How do I pass values from a Gridview to a DetailsView? Treeview script errors (ASP.Net 2.0) |
|||||||||||||||||||||||