Solved

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

Posted on 2007-11-20
2
918 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

743 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

15 Experts available now in Live!

Get 1:1 Help Now