DotNetNuke - Events on dynamically loaded subcontrollers do not fire

Im creating the passage of a site through a module that will dynamically load various controls onto different pages. For some reason, events on the subcontrollers do not fire.

Main view

<%@ Control language="C#" Inherits="DotNetNuke.Modules.SiteWalkthrough.View" AutoEventWireup="false"  Codebehind="View.ascx.cs" %>
<%@ Register Src="/DesktopModules/SiteWalkthrough/Controls/Start.ascx" TagPrefix="sw" TagName="start" %>

<asp:MultiView ID="MultiView" runat="server">
    <asp:View ID="mvStart" runat="server">
        <sw:start ID="ucStart" runat="server"></sw:start>
    </asp:View>
</asp:MultiView>

Code appearance

namespace DotNetNuke.Modules.SiteWalkthrough
{
    public partial class View : SiteWalkthroughModuleBase, IActionable
    {
        override protected void OnInit(EventArgs e)
        {
            InitializeComponent();
            base.OnInit(e);
        }

        private void InitializeComponent()
        {
            this.Load += new System.EventHandler(this.Page_Load);
        }

        private void Page_Load(object sender, System.EventArgs e)
        {
            MultiView.SetActiveView(mvStart);
        }
    }
}

User control

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Start.ascx.cs" Inherits="DotNetNuke.Modules.SiteWalkthrough.Controls.Start" %>

<div>
    <span>Welcome!</span>
    <span><asp:Button ID="btnNext" runat="server" Text="Okay" CssClass="btnNext" OnClick="btnNext_Click" /></span>
</div>

User management code

namespace DotNetNuke.Modules.SiteWalkthrough.Controls
{
    public partial class Start : PortalModuleBase
    {
        protected void Page_Load(object sender, EventArgs e) {}

        protected void btnNext_Click(object sender, EventArgs e) 
        {
            // this event never fires
        }
    }
}

This code works fine with a standard ASP.NET project, but not in DotNetNuke. Do I need to manually register events in OnInit on the main screen?

+3
source share
1 answer

I take a hit, but I think you need to associate the control and the event in _init, not the _load of the control. This is due to the life cycle of the page.

"AutoEventWireup" .

+1

All Articles