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

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

  1. ibejo

    ibejo 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!
    ibejo, Jul 13, 2006
    1. Advertisements

  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

    Alessandro Zifiglio
    Alessandro Zifiglio, Jul 18, 2006
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.