How to prevent JavaScript conflict in custom server control (when added more than once to a page)

M

MGKR

How do you go about solving this?

Ie. unless the JavaScript, included with the server control (which might
reference ID's in the generated HTML), somehow knows which control it
belongs to - A problem will occur if two or more of the same control are
included on the same page.

It's no problem ensuring that unique ID's are generated for each use of a
particular control - But then what with the JavaScript referencing those
ID's?

Are there any general Pattern&Practice for solving this?

I've searched high and low on the net without much luck.

Would very much appriciate some pointers to some links that dig into this
subject..


/MGKR
 
N

Nathan Sokalski

Well, you can always generate a separate function for each instance of the
control and give the function a name like <CONTROLID>_myfunction(). However,
if the JavaScript is being used with instances of the same control there is
usually a way to write it so that the same JavaScript can be used for all
instances, often by passing a few extra parameters. If you tell us exactly
what your control's JavaScript is supposed to do we may be able to make a
few suggestions. Good Luck!
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top