Solved

WebUserControl event not firing.  Is PlaceHolder the problem?  Or the dynamic adding?

Posted on 2007-11-20
2
919 Views
Last Modified: 2008-02-01
I am signing-up for the event, but it is not firing at runtime....

Is the placeholder interfering, or is it the fact that I have to create and add the control dynamicall?

I added the web user control to a new WebForm and the event fires just fine, so the control is capable of raising the event, and web pages can consume it, but for some reason it is not working in my placeholder control.


private void CreateMessageBox(string custommessage, bool YesVisible, bool NoVisible, bool CancelVisible, bool OkVisible, int tempCurrentIndex, bool msgboxvisible)
    {
        Control stepmonitor = LoadControl("..\\scripts\\controls\\FUWStepMonitor\\FUWStepMonitor.ascx");
        members_beta_scripts_controls_FUWStepMonitor_FUWStepMonitor fuwsm = (members_beta_scripts_controls_FUWStepMonitor_FUWStepMonitor)LoadControl("..\\scripts\\controls\\FUWStepMonitor\\FUWStepMonitor.ascx");
        fuwsm.currentIndex = tempCurrentIndex;
        fuwsm.SetVisibleButtons(YesVisible, NoVisible, CancelVisible, OkVisible);
        fuwsm.SetCustomMessage = custommessage;

        fuwsm.YesButtonClicked += null;
        fuwsm.YesButtonClicked += new EventHandler(this.HandleMessageBoxYesButtonClicked);

        fuwsm.NoButtonClicked += null;
        fuwsm.NoButtonClicked += new EventHandler(this.HandleMessageBoxNoButtonClicked);

        fuwsm.CancelButtonClicked += null;
        fuwsm.CancelButtonClicked += new EventHandler(this.HandleMessageBoxCancelButtonClicked);

        fuwsm.OkButtonClicked += null;
        fuwsm.OkButtonClicked += new EventHandler(this.HandleMessageBoxOkButtonClicked);

//ADD CONTROL TO PLACEHOLDER
        msgbox.Controls.Add((Control)fuwsm);
        msgboxdiv.Style.Add(HtmlTextWriterStyle.Position, "absolute; left:30px; top:200px;");

        msgboxdiv.Visible = msgboxvisible;

    }
0
Comment
Question by:knowlton
2 Comments
 
LVL 33

Accepted Solution

by:
raterus earned 500 total points
ID: 20327803
You have to recreate dynamically created controls on a postback if you want the events to fire.
0
 
LVL 5

Author Comment

by:knowlton
ID: 20328474
I found out that you are correct.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Paging GridView 7 48
Hovering effect 9 45
Name space syntax error 12 38
Error in JQuery 5 34
Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now