Click here to Skip to main content
16,018,264 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I'm dynamically loading .ascx in a placeholder inside .aspx
and the placeholder was inside ajax updatepanel.

I have 2 .ascx, when I load the first .ascx then I can execute the javascript inside that ascx. But when I load the 2nd .ascx, it still reads the javascript of the first .ascx, Why is that behaving like that? Can somebody help me how to do it right.

This is how i load the .ascx
VB
Sub loadUserControl(ByVal myControl As String)
   PlaceHolder1.Controls.Clear()
   PlaceHolder1.Controls.Add(LoadControl(myControl))
End Sub

Thanks in advance.

Enan
Posted
Updated 29-Sep-12 7:43am
v2
Comments
Sandeep Mewara 29-Sep-12 14:15pm    
Explain a little more: "it still reads the javascript of the first .ascx"

How do you know this?
Hernan K. Cabrera 29-Sep-12 14:57pm    
Hi Sandeep,

I tried to execute function on onload. eq. alert('User Control 1') for the 1st ascx and alert('User Control 2') for the 2nd ascx with the same function name. Either of the two ascx giving me the same message "User Control 1".
Sandeep Mewara 29-Sep-12 15:17pm    
Do a viewsource of your webpage and see what is there in HTML. Is UC1 still there?
Hernan K. Cabrera 29-Sep-12 15:23pm    
Yes Sandeep, even if I click button that will load the 2nd ascx, I can still see the UC1 alert message function in the viewsource.

But when I tried to comment out the scriptmanager, updatepanel and contenttemplate, it runs correctly.
Sandeep Mewara 29-Sep-12 15:28pm    
Strange. May be caching issue. You sure that alerts are different. Right?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900