Problem in Dynamically Loaded User Control

Feb 28, 2009 at 10:50 PM
First of all, this control looks great.  I just seem to be having one problem in a particular use case scenario when implementing this control.  Everything works as intended in normal ajax pages (update panels or not) however it seems to be rendered useless if placed inside a dynamically loaded user control.  I'm placing it outside an update panel so at first I thought the raised event was being lost between postbacks... but I'm beginning to think it's something javascript related in conjunction with using ajax on these pages despite not being inside an update panel.

Anybody else run into this or have any ideas on work arounds?  Thanks in advance.
Mar 1, 2009 at 11:38 PM
Edited Mar 1, 2009 at 11:39 PM
Yes if the control is dynamically loaded the JavaScript does not get initialized. There is a way by using one instance on the page and making it visible and invisible and reinitializing it with JavaScript code but I won't have time to give you exact example. The basic idea is shown here:

<script type="text/JavaScript">
// initialize on the page load

// function called BEFORE ParentDiv is reloaded
function BeforeReload(){

// function called AFTER ParentDiv is reloaded
function AfterReload(){
<div id="ParentDiv">
  <fjx:FileUploader ID="FileUploader1" JsFunc_Init="InitUploader" JsFunc_Dispose="DisposeUploader" runat="server">
          <fjx:FileSaverAdapter Runat="server" FolderName="UploadFolder" />
Mar 2, 2009 at 12:47 AM
Thanks for the quick response flajaxian.  I have to wonder where you find the time to both make your control look this good support your community here to answer questions.  I was beginning to think of workarounds for this problem too and was beginning to think of a solution like the one you were mentioning (or simply not adding the control dynamically but make it always there but simply invisible/visible).  Your pasted javascript code to handle the init/dispose was priceless though.  I'll try giving this a shot and see if it works.  Thanks a lot.
Mar 18, 2009 at 9:32 PM
Thanks for this control.. I am hoping it will solve my situation... but its not quite running yet.  I think I have the same problem.. I have it in a Usercontrol, and I tried adding the code above, but I am getting the error: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

I know its tough to debug from a distance, but Any help is appreciated !!!