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

Discussion in 'ASP .Net Web Controls' started by ibejo@ibejo.com, Jul 13, 2006.

  1. Guest

    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!
    , Jul 13, 2006
    #1
    1. Advertising

  2. 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

    <> ha scritto nel messaggio
    news:...
    > 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!
    >
    Alessandro Zifiglio, Jul 18, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marcelo Birnbach [MS]
    Replies:
    0
    Views:
    3,309
    Marcelo Birnbach [MS]
    Jun 28, 2003
  2. Kylin
    Replies:
    1
    Views:
    376
  3. David Hubbard
    Replies:
    2
    Views:
    818
    David Hubbard
    Jan 12, 2006
  4. Jack Steven
    Replies:
    2
    Views:
    418
    Chris Rebert
    Mar 9, 2009
  5. santoshp

    Dynamically adding multiple instances of same usercontrol

    santoshp, May 30, 2007, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    199
    santoshp
    May 30, 2007
Loading...

Share This Page