Anyname Donotcare
Anyname Donotcare

Reputation: 11403

The Controls doesn't appear in the design mode (design time)?

I have the following problem with specific user control :

It appears white and no control appear at all in (design view).(design time)

but the source :

<%@ Control Language="C#" AutoEventWireup="True" CodeBehind="Follow_New.ascx.cs"
    Inherits="DFUI.UserControls.Follow_New" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register Assembly="MattBerseth.WebControls" Namespace="MattBerseth.WebControls"
    TagPrefix="mb" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
.
.
.
.
.

What's the problem how to show all the controls to edit in design view rather than troubled with the source view ?

Upvotes: 1

Views: 2082

Answers (3)

Nirav
Nirav

Reputation: 187

Did you checked that Design View is on ? Goto Options > Show All Settings > Scroll to HTML designer > Select Enable HTML Designer (Will require to restart VS)

Another reason may be broken HTML, open your ASCX ( not the code behind ) and just press CTRL+K then CTRL+D.

Upvotes: 1

CodeMonkey1313
CodeMonkey1313

Reputation: 16011

If you're trying to get the controls to show up in the toolbox you may need to manually add the dlls you're referencing to the toolbox. Right click in the toolbox then browse to the location of the dlls you're referencing and select the ones you need. This will make any controls that are properly marked (marked in the way that @gregor-primar describes) show up in the toolbox.

Upvotes: 1

Gregor Primar
Gregor Primar

Reputation: 6805

One way to ensure that your control can be "visible" inside design view you can override render like this:

    protected override void Render(System.Web.UI.HtmlTextWriter writer)
    {
        if (this.DesignMode)
        {
            //render control for designer...
            writer.Write(string.Format("<div>{0}</div>", this.ID));
        }
        else
        {
            //render actual control in runtime...
            base.Render(writer);
        }
    } 

To enable control editing inside designer you should inherit from INamingContainer, here is simple demo:

[ToolboxData("<{0}:TabContainer runat=server></{0}:TabContainer>")]
[ParseChildren(ChildrenAsProperties = false)]
[PersistChildren(true)]
public class TabContainer : Panel, INamingContainer
{

    List<TabItem> tabs = new List<TabItem>();

    [Browsable(true)]
    [PersistenceMode(PersistenceMode.InnerProperty)]
    public List<TabItem> Tabs
    {
        get { return this.tabs; }
    }
}

public class TabItem : Panel, IPostBackEventHandler
{

    public event EventHandler Click;

}

So design view would look something like this:

        <cc1:TabContainer ID="TabContainer1" runat="server">
            <Tabs>
                <cc1:TabItem ID="TabFirst" />
                <cc1:TabItem ID="TabSecond" />
            </Tabs>
        </cc1:TabContainer>

Hope this helps!

Upvotes: 1

Related Questions