Home All Groups Group Topic Archive Search About

UserControl loaded dynamically multiple times on same page....client js problem

Author
13 Jul 2006 2:10 AM
ibejo
OK - I have a user control that I have written.  I load it multiple
times on the same page with different data.  It uses a server side
javascript file that contains some DHTML / JS.  The problem appears to
be that since each instance of the control shares the same .JS file,
there appears to be collisions where one control is overwriting values
in the .JS that was set by the other control.

Is there some way to have each user control have its own instance of
the same JS file?

Any help greatly appreciated!

Author
18 Jul 2006 7:30 AM
Alessandro Zifiglio
hi, this is basically a scripting issue, that you should try and resolve in
your js.
Your js needs to be able to deal with multiple elements calling and using
the same piece of code while preserving scope.
Try an object oriented approach in you way of writing js code, this way for
each element you can instiantiate a new object with the new operator, and
each call will run within its own scope. Currently your code seems to be
running within a global scope, so its normal that they override values,
specially if you have some variables declared outside your functions these
run in globalscope and are probably the root cause of the problem you are
having.

Regards,
Alessandro Zifiglio
http://www.AsyncUI.net

<ib***@ibejo.com> ha scritto nel messaggio
Show quoteHide quote
news:1152756615.692252.239200@35g2000cwc.googlegroups.com...
> OK - I have a user control that I have written.  I load it multiple
> times on the same page with different data.  It uses a server side
> javascript file that contains some DHTML / JS.  The problem appears to
> be that since each instance of the control shares the same .JS file,
> there appears to be collisions where one control is overwriting values
> in the .JS that was set by the other control.
>
> Is there some way to have each user control have its own instance of
> the same JS file?
>
> Any help greatly appreciated!
>