Re: Decoupling javascript from UserControls

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Ole Viaud-Murat <o.viaudmurat@xxxxxxxxxxxxxx> wrote in news:7c87fac8-
2237-4c5e-95ab-29b9317ceff3@xxxxxxxxxxxxxxxxxxxxxxxxxxx:

Thank you so far.

But i dont understand you completely. I'm neither planning to change
the ajax js libs nor to the load-behaviour of those.

In some of our UserControls there are javascript blocks, for example
to handle certain events of commercial controls eg. the SelectedItem
Change of a ComponentArt ComboBox.

The problem is, that those js blocks are scattered throughout the html
response that is sent to the browser. And i want all of the JS to be
loaded from files, to remove them from the UserControl-Markup, to make
them cacheable for the client and to centralize all JS source.

I guess the main problem is, that i'm using constructs like

var el = $get('<%= tbSomeControl.ClientID %>');

Probably i should try to remove those Server-Side Client-ID generation
and get those a different way.

I dont know if i understood you wrong or if my question was unclear,
perhaps you know now what i mean?

For now, we have to stick to asp.net 3.5 in Forms mode, though we
consider using asp.net MVC in the near future.

If you are using third party controls, it gets more difficult. Some of
hte libraries use external files already, but many emit JavaScript, as
you have pointed out.

Can you consolidate? Certainly, but the calls are still going to be
emitted unless you can control the output (exposed or deriving your own
class from theirs, and it is possible neither will be supported).

I am not sure I see anything wrong with $get() except perhaps
maintainability.

Good luck on this one, as I am not sure there is an easy solution,
especially if you are attempting to consolidate numerous libraries. It
also sounds very custom.


--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
.



Relevant Pages

  • Re: Theory of beliefs, belief fields
    ... real thing, and chromed switches resembling the real thing, and some LED ... and proprietary bar controls and I dont remember if last working ... version had knob controls on the guitar though they dont seem to useful. ... I was supposed to scratch with wood. ...
    (sci.econ)
  • Re: Interface question
    ... > I don't particularly like that sort of use for UserControls. ... > where you have a set of intrinsic controls ... > to raise events, thus, an indirect route) But since your form is pretty ...
    (microsoft.public.vb.general.discussion)
  • Re: Events for programmatically created controls?? how..
    ... > So in ASP.NET we may use viewstate to store variables in a page scope but ... called I run my buildPage routine which programmatically adds all the ... these controls in the sense of: strText = txtTextbox.Text for example - ... maybe it does...I dont know... ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Deploying a VB.NET Application to IP site
    ... if they dont open an account with http://www.brinkster.com/ and upload your ... > WEB Page provider by my Internet Provider. ... > no TEXTBOX or Button controls present? ... > I have loaded up a personal site using MS Publisher previously without any ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: why usercontrol_initialze on unload form?
    ... Now I found that some of the usercontrols' doInitialize and ... doResize subs are called not only on form load event when all controls are ... Run & Terminate Project ... Private Sub UserControl_Initialize ...
    (microsoft.public.vb.general.discussion)