Problem: I have a user control (.ascx) with a ton of javascript code in there. I have two instances of the user control on the same page. When the code runs the two user controls behave erratically because all the js objects with the same name can only have one value (including functions). The javascript is in the code behind and it is registered via "ScriptManager.RegisterStartupScript(.....)".
I've searched thoroughly and although there are a few threads with suggestions I found nothing that works other than literally going through the whole user control and appending an ID to function names that raise collision problems. (which requires meticulously going through all the code and deterimining if it is problematic).
example:
Dim asdf As String = ""
asdf &= "function foo" & UNIQUE_ID & "() {" & vbCrLf
asdf &= .....u get the idea......
asdf &= "}"
Is there a more elegant solution than this? Is it just bad practice to put javascript inside user controls for this reason?