Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0How to register Event Handlers for dynamic loaded UserControlHow to register Event Handlers for dynamic loaded UserControl
Previous
 
Next
New Post
12/24/2008 1:20 AM
 

Issue : When loading dynamic UserControl Event handlers are not get registered

I am using Dnn 4.8.4

I am loading Dynamic Control at runtime to a module , by using Load Control() function . I am getting design view of that control . But I am not getting any event handlers of the dynamic control . I mean button click , ddl postback events ....  of the control are not register while loading dynamically .

thanks to all for ur help

 
New Post
12/24/2008 8:25 AM
 

Without seeing your code for loading the control dynamically it is difficult to help but I would suggest you check the following:

1. Make sure that you are loading the control on every postback (outside of  Not IsPostback block).
2. Check that the Cache Time for the module is set to 0.

If that doesn't help, please post your code for loading the control. Also, is the control a UserControl or a DNN module control which inherits from PortalModuleBase?


Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
New Post
12/26/2008 1:49 AM
 

Thanks William but still i am not getting Event handler

I am calling outside PostBack , loading the control every postback , and made cache to zero , Still I am not getting the Event handler of the  ViewCMSContentModule.ascx ( button click ,.... ) 

My code as follows

 

  setPanel("~/DesktopModules/ContentManagementSystem/ViewCMSContentModule.ascx")   ' Outside postback

 

 Private Sub setPanel(ByVal ucVirtualPath As String)
            Dim uc As New UserControl
            uc = LoadControl(ucVirtualPath)
            uc.DataBind()
            pnlTemplate.Controls.Add(uc)

End Sub

 
New Post
12/26/2008 7:37 AM
 

I also tried to use PlaceHolder instead of Panel , bt still I am unable to call my even handlers

My code as follows

 

  Private Sub setPlaceHolder(ByVal ucVirtualPath As String)
            Dim objModule As Entities.Modules.PortalModuleBase = CType(Me.LoadControl(ucVirtualPath), DotNetNuke.Entities.Modules.PortalModuleBase)
            If Not objModule Is Nothing Then
                objModule.ModuleConfiguration = Me.ModuleConfiguration
                plcHolder.Controls.Add(objModule)
                'ClientCallback(Logic)
                DotNetNuke.UI.Utilities.ClientAPI.HandleClientAPICallbackEvent(Me.Page)
            End If

 
New Post
12/26/2008 9:49 AM
 

Are you assigning an event handler anywhere for it to handle?

something like
uc.OnClick += new EventHandlet(uc_OnClick(...)); //Or something like that, VS lets me use the Tab key to make it go
Then have a function 
protected void uc_OnClick(object sender, EventArgs e){...}

 

To handle the event of a control in the loaded usercontrol, the user control will have to bubble up an event such as the button click; something like this

 

   private void Button1_Click(object sender, System.EventArgs e)
   {
      Response.Write("WebUserControl1 :: Begin Button1_Click <BR>");
      OnBubbleClick(e);
      Response.Write("WebUserControl1 :: End Button1_Click <BR>");
   }

   public event EventHandler BubbleClick;

   protected void OnBubbleClick(EventArgs e)
   {
      if(BubbleClick != null)
      {
         BubbleClick(this, e);
      }
   }           

 

Then, in the control that you loaded the user control you will want to do something like

uc..BubbleClick += new EventHandler(uc_BubbleClick);

protected void uc_BubbleClick(object sender, EventArgs e){...}

 

I hope that helps.

 

Because I don't use it often enough and have to reference my old code, or the internets, my examples were slightly modified from the code found here.

 

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0How to register Event Handlers for dynamic loaded UserControlHow to register Event Handlers for dynamic loaded UserControl


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out