Removing Dynamic Controls

when i post back and my pages calls LoadViewState(object) and then calls "CreateChildControls" how can i handle removing controls if that value of what control i should remove does not get set in the viewstate until the click event of my button???? which means i wont have the value of the removed control until it post back again....which will leave me with having to click my delete button twice to remove the control from the page...any help on how to firgure this out??

Give Yourself a round of applause!
11/8/2007 8:58:54 PM 3498 articles. 0 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 29

What you need to do is Get rid of CreateChildControls because u need to update your view state before your UI will reflect the changes.....Next u should get the id of the control that is calling this event in the button CLick event or where ever like so

    public void btnDelete_Click(object sender, System.EventArgs e)
        NumberOfControls -= 1;
update the viewstate property then pass the sender down to another method in which will remove your controls from the list like so
     public void RemoveControl(object ControltoRemove)

        Button deleteButton = (Button)ControltoRemove;
        string ClientID = deleteButton.ClientID;
        ClientID = ClientID.Replace("WucTimeWorkedGrid0_", String.Empty);
        ClientID = ClientID.Replace("_btnDelete", String.Empty);

        Control crtl = (Control)UiTimeWorkedContainter.FindControl(ClientID);
        if (crtl != null)
            int index = UiTimeWorkedContainter.Controls.IndexOf(crtl);
           if (index >= UiTimeWorkedContainter.Controls.Count)
               index = index - 1;
               crtl.Visible = false;
               crtl.Visible = false;
 And that is how u can remove Dynamic controls and have them be refelcted in the UI when the delete button is clicked.....thanks...HAPPY CODING!!!

Give Yourself a round of applause!
11/9/2007 6:21:54 PM

Similar Artilces:

Dynamic Slave Controls
I am working a solution to enhance slave controls. I have created a proof of concept based on the 2.04 code base that shows how to load slave controls without switching to the admin view. I have included a sample module that contains 3 view controls. Each control has a row of buttons that can be used to load one of the other 2 controls. (and no I am not using panels.) The default control has a drop down of other instances of the dynamic control that exist on the current tab. Using the module communicator you can raise an event from one control that tells another instance of the module what c...

Usercontrol vs Custom Server Controls, Any need for Custom Server Controls
Hello I'm new to ASP.Net so this is probably a stupid question but, is there any need to create customer server controls now that you can pre-compile usercontrols into a dll and thus easily share between applications? This blog post from David Ebb describes how to do it and the restrictions he note don't seem that bad (other than being able to embed resources such as images in the dll). His article desribes the techniques for ASP.Net 2.0 and he suggests that there will be further improvements in .Net 3.5 in this ar...

how to have both server controls and html controls rendered in a custom control?
I have a custom control in which there is an html text box.when you click on it , a div containing a table is appeared and according to what you select in that table a text is set to the text box. It works fine but the problem is: as the text box is an html element it doesn't have viewstate and when a post back occures in the page its value disappeares.I tried a hidden field to keep its value.again there is another problem : I put this custom control in a usercontrol and put the usercontrol in a multiview and by clicking on a button this view is selected and by clicking another bu...

Custom Server Control Vs Web Parts, Any need for Custom Server Control
Hello I've just posted a similar question on why you need server controls when you can pre-compile usercontrols and redistribute them. I've seen lots of (usercontrol vs web part) but not much on web part vs custom server control. According to the MSDN site you can put web parts onto a normal page outside of a web part zone and they behave just like custom server controls. So, if you are creating a bunch of controls for redistribution to customer sites and/or SharePoint sites why don't you just create Web Par...

problems listenening to events on a custom server control from another custom server control
 Hi all,I am having problems listening to events on one of custom server controls(AddBookmark) from another custom server control(BookmarkList). The listener or the BookmarkList control has a property that can be set to the AddBookmark control (string at design but the reference is obtained at run-time). I am able to get a reference to the AddBookmark control and add a listener to it on the BookmarkList control on the OnPrender of BookmarkList. But the problem is that when the events on AddBookmark gets fired, the listener added from the BookmarkList is no longer present and the listene...

Custom Server Control Made of Custom Controls?
I'm giving myself a crash course in custom server controls, and I have a quick general question. Can I have a custom server control that is composed of other server controls I created. I'm pretty sure the answer is yes, but I want to be positive. Yes Shows how to combine existing controls into a new control using class composition. -ron Thanks! ASP.NET so rocks! Making page components extensible objects is such a great idea! I love it....

Dynamically Loaded User Control inside Custom Server Control Weirdness
Hello, I have a wizard controller server control that walks the steps of a wizard and dynamically loads the user control to display for the wizard page using Page.LoadControl. Everything is working great! Until this showed up. One of the controls on the user control is another custom server control. This server control on the dynamically loaded user control makes use of RegisterClientScriptBlock. For some reason, the client side code for RegisterClientScriptBlock never gets rendered! I stepped through the code to ensure that RegisterClientScriptBlock gets called, it does. If I ...

Why can't I add controls dynamically to my customer server control?
This is a simple example of a custom control where I dynamically add a new control to the hierarchy. The problem is when I click the 'C' button, it adds the B button and then the next click of the 'C' button will hit the B_Click event handler. My only theory is that since it was added to the middle of the control heirarchy, then event handling got confused. Has anyone seen this problem or am I doing something wrong? using System; using System.Configuration; using System.Collections; using System.Text.RegularExpressions; using System.Xml; using System.Data; using S...

Dynamic custom control on custom control
What I'm trying to do is create a module for use within a larger page.  The page itself is an order form, which will have typical payment info (address, credit card, etc.), and the ability to select what you are paying for.  Our clients will have several options in how they want the page setup.  They can either have a single form, or they can have each module on it's own page.  They can also have all the selected items fire in a single transaction, or have a seperate transaction for each item selected.  And they can limit the total number of transactions a person can...

Custom Control within a Control Control
I am developing a custom controls that will render headers for different web sites. Within these controls, I want to place another custom control that will change the language. I created the language control and had it implement IPostBackDataHandler. This control works fine if I drag it on a new web form, but if I tell a header custom control to render it problems occur. The Language Selector custom control does not have a Page member anymore and the event handlers do not work. Does anyone have any experience with doing something similiar? Anyone have any suggestions? Thanks, ...

Custom Server Control with Child Controls
I have a custom server control <xx.Parent... /> which parses custom child controls <xx.Child... />. In Visual Studio 2008, IntelliSense shows me both when I start typing my control namespace. How can I prevent the child control from showing up in IntelliSense  unless I'm adding it within the parent tags?Thanks. --Rudy...

Custom Server Control With Child Control
All, I am currently putting together a very simple control. The new control outputs a table with two rows. The top row contains a heading and the bottom row will contain any other content. The control as it stands works perfectly well and I can place text into the content row no problem. Now, to the problem. Once I'd completed the control I figured it would be neat to enable the developer to add controls directly into the bottom row (content row) of the outputted table. As you probably know the WebControl class has a Controls collection which the developer can use to add any other...

Creating .Net custom server controls and .Net pages programatically
Thanks a lot for reading this and greatly appreciate your inputs I am writing a webinterface that lets users configure options that'll create an interface for them and generete the webpage. So I am having to programattically create custom server controls and .Net page with code behind to support the functionality. Are there APIs in the .NET SDK that let you do this. Any pointers would be greatly helpful Thanks a lot Sathya Controls on the fly? Or Create code on the fly? I think it is the latter so here we go - look at the following namespaces: * System.Reflection.Emit - gen...

What is the real difference between Server Controls and .NET controls?
This was a class discussion question and I'd like to know, what exactly are the differences? Is there a clear answer? .NET framework controls are server controls. The only difference that I can think of is that the .NET controls are part of the FCL (Framework Class Library). HTH,RyanRyan OlshanASPInsider | Microsoft MVP, ASP.NEThttp://ryanolshan.comHow to ask a question...

handling events for controls in custom server control
Hi,     I am having a problem in using server controls in ASP.Net, with C#.  I am trying to create a server control which contains 2 other server controls that I created (Called MyImageButton).  MyImageButton extends the standard ImageButton with some other properties & methods that I needed.  It therefore also has the 'OnClick' event.  From the original server control, I would like to handle the Click event for these 2 image buttons in the same server control.  Basically, this server control will show 2 images, ascending and descendin...

Web resources about - Removing Dynamic Controls -

Facebook Removing Outdated School Info from Some Users’ Timelines?
It appears that Facebook is in the process of reminding users that they are no longer in college , as some users are seeing notices that their ...

Removing App Profile Pages
Today, we are announcing that we will remove all App Profile Pages on February 1st, 2012. Though similar in appearance, the automatically generated ...

Friends Checker Tracks Who’s Removing You From Their Facebook Friends List
Last week, Facebook reminded users that when they ignore friend requests the requesting party is not notified, but a new Greasemonkey script ...

Removing the 140-character limit from Direct Messages
If you’ve checked your Direct Messages today, you may have noticed that something’s missing: the limitation of 140 characters. You can now chat ...

Flying Fish, Great Dish (Part 1: Introduction & Removing Filets) - YouTube
Asian carp is an invasive fish species that has rapidly taken over ecosystems in parts of the Mississippi River and Missouri River regions. These ...

Kmart joins Target in removing GTA5 video game from shelves after online campaign
Target has bowed to pressure from an online campaign calling it to pull popular R-rated video game Grant Theft Auto V from its shelves.

Removing the rorts
Professor John Freebairn, veteran analyst of public policy, believes the Commonwealth spends an unsustainable amount on 'middle-class welfare'. ...

France: officials start removing 1 million 'love locks' from Paris bridges
Paris, known worldwide as the city of romance, on Monday began removing tens of thousands of &quot;love&nbsp;locks&quot;, padlocks chained to ...

Roger Rogerson and Glen McNamara seen on CCTV removing body of Jamie Gao from storage unit
ROGER Rogerson and Glen McNamara were captured on CCTV &#8220;bending, lifting and kneeling down&#8221; as they &#173;removed the body of shooting ...

Bud Light beer ads: “Removing no from vocabulary” outrage - Business News - Business and Finance News ...
US BEER brand Bud Light has apologised and retracted a slogan which suggested having a drink would remove the word &#8216;no&#8217; from your ...

Resources last updated: 12/1/2015 4:59:15 PM