WebForm designer doesn't generate html code when I add child controls in DesignerActionMethodItem RRS feed

  • Question

  • User338276796 posted

    Hi, all.

    I have a custom asp.net control and I want to give it some design time support, so I create a control designer, and override its ActionLists to return my custom DesignerActionList inherits from DesignerActionList class. I override the GetSortedActionItems property to add a DesignerActionMethodItem, which will create some child controls when user click it. the c# code just like this:

    public override DesignerActionItemCollection GetSortedActionItems()
                    if (_actionItems == null)
                        _actionItems = new DesignerActionItemCollection();
                        _actionItems.Add(new DesignerActionMethodItem(this, "AddNewCell", "add new cell", "Behavior"));
                    return _actionItems;
                public void AddNewCell()
                    InvokeTransactedChange(Component, DoAddNewCell, "AddNewCell", "add new cell");
                public bool DoAddNewCell(object args)
                    ObjectContainerCell cell = new ObjectContainerCell();
                    PropertyContainer property = new PropertyContainer();
                    PropertyContainerCell pc = new PropertyContainerCell();
                    pc.Controls.Add(new Label());
                    pc = new PropertyContainerCell();
                    pc.Controls.Add(new InputControl());
                    return true;

    I test it in vs 2008, I saw the action list with an "add new cell" hyperlink on it. When I click this hyperlink, the design-view of vs 2008's web form designer shows me the change my code have made correctly, but when I switch to the html-view, nothing expected code was generated.

    But, if I change the id of the added child control or resize it, the control's code was generated in html-view.

    I have another control designer with the similar function, but it can generate code immediately when the hyperlink such as "add new cell" was clicked. But I can't find the difference between them.

    I guess that I should call some method to enforce the web form designer to update the aspx file, just like the ControlDesigner.UpdateDesignTimeHtml() to enforce the designer-view to refresh the design time html.

    can anybody help me?

    Monday, November 16, 2009 2:51 AM


  • User338276796 posted

    maybe there are something wrong in my vs 2008, I have tried in another computer and it works well. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, November 17, 2009 8:00 PM