Dynamically loaded Web User Control .ascx button click event handler not called on second time click

I have an ascx control (that performs actions for an entity) being added dynamically to accordion panes, and then the panes are added to an ajax accordion control, so that the accordion can contain multiple panes with each pane containing one ascx control. The ascx control contains a delete button which removes the entity from the database. Once the entity is removed, I need to reflect this deletion in the parent page by removing the accordion pane from the accordion. To do this I created a delegate function and which is called from the parent page to rebind the accordion and hence not display the recently removed control (the entity). If perform the delete operation for a ascx control it works the first time I attempt to remove any control. The accordion is rebinded and there is one less accordion pane with the control because or the deletion. If I try to click the remove button of a control the second time, the event for the delete button is not fired in the ascx control. I am generating the ascx controls and binding them to the accordion on Page_Init in the parent page so that the event handlers for the ascx control are properly called. So does anyone have an idea why the events are handled by the ascx control the first time and not the second time around?

 Thanks in advance.

0
gjgomez
2/20/2009 9:06:34 PM
asp.net.web-forms 93655 articles. 6 followers. Follow

1 Replies
1488 Views

Similar Articles

[PageSpeed] 52
Get it on Google Play
Get it on Apple App Store

Hello gjgomez,

Could you post the code where you dynamically create  the delete buttons?

Also, just for fun, comment out the line in your event handler where you delete the entity from the database.  Do the events now fire as expected or are they still broke 2nd time around.  If they fire ok, make sure you're setting the ID for your dynamcially created controls.  ASP.NET will use these ID's when wiring up the event handlers.

If you don't set them, they'll be auto-generated... and will wack your event handlers as you add/remove controls.

~Rick


Please mark the post as ANSWER if it helps you

Disclaimer: Just my opinion. Not my employer or anyone else....
0
Rick
2/20/2009 11:43:07 PM
Reply:

Similar Artilces:

To access a control placed in a web user control which is loaded during page load in button click event
How can I access a control in a web user control in a button click event , the user control is loaded in page load.Thanks & Regards,Abhiram Reddy Mekha. Try checking this... http://microsoft.apress.com/asptodayarchive/73869/event-handling-between-custom-user-controls-that-are-loaded-at-run-time http://aspalliance.com/565_Dynamic_Loading_of_ASPNET_User_Controls http://www.beansoftware.com/ASP.NET-Tutorials/Controls-Run-Time.aspx http://stackoverflow.com/questions/92792/user-control-created-dynamically-not-able-to-handle-events-on-postback http://www.codersource.net/asp_net_user_c...

Error when Loading Dynamic UserControl from current User Control's Button Click event Calling Page Event
Hi,I have a panel that I load user Control in no problem.  The problemarrises when I do a post back on one of these user controls.  I havebutton it does a click event.  In this click event I will do somedatabase updates, then I will use reflection to call a method in theparent (this.page) to load the new user control.  Its at this pointafter it loads the new user control that it throws the error "Thecontrol must be placed inside a form tag with runat=server".Now, my methods that managers the user control works.  I am able toclick on the parent page menu and...

button click handler on .aspx page for user web control button
Hi guys,  I have a web user control which contains my search function(some textfields and a button named btnSearch).  I create a web part manager and a web part zone to put the web user control in it to allow the user to minimise/show the search function   In my web page(.aspx), I have a nested datagrid and the web part manger and the webpart zone. Is there a way get the event handle for the btnSearch.click in the aspx page? This is to allow me to filter the datagrid based on the search critial given in the search function...

Dynamically loaded user control with a button doesn't fire its button click event?
I have a datagrid, in which one of the columns is 'button' column called 'Send Email'. When I click on this button, then an email user control is dynamically loaded into a placeholder above the datagrid header area. The email control renders correctly, but when I click on 'Send' button in this user control, then the click event of this 'Send' button doesn't fire. This is even though the 'Handles.btnSend.Click' is there for the click method of the 'Send' button. Can someone please tell me why the event is not firing and what do I need to do to make it fire?    sun21170 you have...

Button Click event in web user control
I've got a web user control that contains a text box where users can perform a search.  I've got a button that performs the search, and I'd like users to be able to type something in the text box, press enter, and have the button-click event fire. however, what's happening is that they are typing a search phrase in the text box, pressing 'Enter' and instead of firing the search button event, it's firing the button click event for the buttons that i've put in the page, not in the web user control.  there is an article on 4guys that suggests adding an additional ...

Web User Control - Button Click
I have a web user control which is has one Button control on it. It has a event for handling the click... if I put this user control ( button ) at the top  of the page, the click event does not get fired just page is refreshed...but where as if I move to the bottom of the page, ButtonClick is fired ???? I am completely clueless why is this change of behavior with respect to the position of the control?? Thanks. could you show us the code that you have problem with ...   Here is the code ( i have taken out the unwanted part of the page ) Please note that the bSave does ...

User Control Button Click Event Does Not Fire With Postback, when Loaded Dynamically
My application consists of a web form (MainForm.aspx) with a PlaceHolder (phMain) with several user controls that are loaded and removed dynamically based on the context. Two of these controls are LoginUC.aspx and DataEntryUC.ascx. Each of these controls have a 'Submit' button.When the application is launched, LoginUC is loaded to the PlaceHolder. Users enter an Id and Password, then upon authentication an event named  LoginCompleted.is raised in LoginUC. This event (LoginCompleted) is consumed in the parent form (MainForm.aspx) wherein the LoginUC control is removed...

Please Help-Problem with loading user control in a button click event handler
Hi, I desperately need some help on how to handle this problem. I have a user control that takes one parameter and displays data in a datagrid. I have an aspx page where I have a set of link buttons. I dynamically load the above user control on the page in the click event handler of these link buttons. When I click on a link button, not only the aspx page but also the user control is taking this as a postback and so some of my code which is wrapped inside the If ( ! (IsPostBack)) does not run. And that screws up my code. Can anybody tell me how to solve this pro...

tabs control .. how to load web control on user click?
hello , i have a simple question how do i load a control like ( LastNews.ascx )  to a tab  when the user click on it?  Hi,You may achieve it in this way:1. Add a UpdatePanel into the tab2. Add a invisible button in it as a trigger for the UpdatePanel3. In the click event of the button, load the UserControl into the UpdatePanel4. Add  an event handler to the activeTabChanged event of the tabContainer.5. In the handler, trigger the click event of the invisible button Hope this helps. ...

Web User Control loaded into updatePanel click events causing entire page to reload
 Hi im sorry for having to ask this but i have tried numerous appraoches and i cant figure out where i am going wrong, i have created a web user control call sampleControl i load this dynamically into my main page which contains a panel, i create the sampleControl for the number of records pulled out of my database based on a stored procedure.The sampleControl has an updatePanel containing everything else within the web usercontrol, and the page the controls get loaded onto have a scriptmanager , Everything up until this stage is working fine i have methods to set images etc the images ...

Click event available to web control within user control? How?
I have a main .aspx page.  I am using code behind, developing with Visual Studio Pro 2003.  I have a user control (.ascx) on my main page.  Inside that user control are web server controls (namely LinkButtons).  I want to have all the LinkButtons to point to one click event.  That click event will identify the LinkButton by its ClientID and perform an action accordingly.  Within the LinkButtons, do I type OnClick="myClickEvent"? Where (in what .vb file) do I put the click event and how do I point all the LinkButtons to fire it when clicked. If I doub...

Web page .aspx is slow when loading. Pages have web user controls on them that are loaded dynamically
I have written a web application using VS 2003. Several of my forms have web user controls on them. The controls are loaded dynamically at runtime. The problem is that the web pages are very slow to load. Does anyone know if there is a way to speed up the pages being loaded into the browser? Here is an example of some code I use to dynamically load the controls:  private void Page_Load(object sender, System.EventArgs e)  {   // Put user code to initialize the page here   // Put user code to initialize the page here    Co...

click event of an user web control
Hello,I've done an user web control made up of an image and a label. I would like to create an event which produce every time I click anywhere on this user control. How can I do this ?I've found on internet that I can use the ControlDesigner class like this : using System;using System.Web.UI.Design;using System.ComponentModel;namespace WebLibraryNet2{public class DesignerAvecClick : ControlDesigner{private ControlAvecClick ctrl;public override void Initialize(System.ComponentModel.IComponent component){if (component is ControlAvecClick){ctrl = (ControlAvecClick)component; }base.Initialize(co...

Web User control click event
I have a Button in WebUserControl and I am using that in ASPX page. I am trying to capture Button click event. Even I have a break point there its not stopping.. see the code below.. UserControl Code:<%@ Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl.ascx.cs" Inherits="WebUserControl" %> <asp:Button ID="btnWUC" runat="server" Text="Click Me!" BackColor="Khaki">   using System; using System.Collections; using System.Configuration; using System.Data; using System...

Web resources about - Dynamically loaded Web User Control .ascx button click event handler not called on second time click - asp.net.web-forms

Placebase team at Apple file “Schematic Maps” patent dynamically detailing important data
In a report from Computerworld way back in 2009, we learned that Apple had quietly acquired Maps API company Placebase. Then, founder of Placebase ...

Apple's Lightning port dynamically assigns pins to allow for reversible use
... a closer look at how Apple's new Lightning connector works, and has come to the conclusion that the 8 pins on each side of the plug are dynamically ...

In a dynamically typed language, is it a bad idea to return different data types?
In some cases, returning different types from a single function works.

Urlbox Launches Screenshots-as-a-Service Platform to Dynamically Update Galleries
... changes. Launched yesterday, Urlbox allows anyone with a gallery displaying website screenshots to automate the process and keep them dynamically ...

Everything.me launcher dynamically adapts to what you’re doing right now
... phone according to what you’re doing. Perform a search for ‘football’ and your background will change to the NFL logo. A launcher that dynamically ...


A YouTube Experiment Resizes the Player Dynamically
There's a new YouTube experiment that changes the video player's size, depending on the browser window's size. When resizing Chrome's window, ...

Apple Granted “Dynamically Changing Cursor for User Interface” Patent, Originally Filed in 2003
... a utility patent that covers the use of the mouse cursor that changes according to the context of the task it is engaged in. Called a “Dynamically ...

Atmel's FPSLIC II Dynamically Reconfigurable SoC Supports "Silicon-Sharing" For Peripherals & Interfaces ...
Silicon-Sharing Fits 200K Gate Design into 40K Gate FPSLIC II's, Cuts Power Drain by 97%

Everything.me Launcher Wants to Dynamically Change Phones Based on Location, Interests, and Mental State ...
What if your phone’s launcher dynamically changed based upon interests, your location, or topics you had in mind at a specific moment? A new ...

Resources last updated: 12/14/2015 9:03:25 AM