ASP.NET Custom control with collection property

Discussion in 'ASP .Net' started by -=Chris=-, May 22, 2004.

  1. -=Chris=-

    -=Chris=- Guest

    Hello all,

    I've designed a custom bread crumb control for several of my asp.net
    projects. The default property of this control is a custom
    HyperLinkCollection I've created, which contains, you guessed it, HyperLink
    objects. All of it works great if I create/assign the links at runtime in
    code. I'd like to be able to assign links at design time, which is possible
    using the properties window, but currently, they do not carry over to the
    runtime. I'm trying to figure out how to make this happen. Sample code for
    the small breadcrumb class is listed below. I would greatly appreciate any
    input.

    using System;

    using System.Collections;

    using System.Web.UI;

    using System.Web.UI.WebControls;

    using System.ComponentModel;

    namespace Com.L3Software.Web.Controls {

    /// <summary>

    /// Summary description for Breadcrumb.

    /// </summary>

    [DefaultProperty("Crumbs"),

    Designer("Com.L3Software.Web.Controls.BreadcrumbDesigner"),

    ToolboxData("<{0}:Breadcrumb runat=server></{0}:Breadcrumb>"),

    Description("A reusable breadcrumb component")]

    public class Breadcrumb : System.Web.UI.WebControls.WebControl,
    INamingContainer {

    private HyperLinkCollection mCrumbs;

    [Bindable(false),

    Category("Appearance"),

    Description("An ordered list of links to be displayed")]

    public HyperLinkCollection Crumbs {

    get {

    return this.mCrumbs;

    }

    }

    public Breadcrumb() {

    this.mCrumbs = new HyperLinkCollection();

    }

    /// <summary>

    /// Render this control to the output parameter specified.

    /// </summary>

    /// <param name="output"> The HTML writer to write out to </param>

    protected override void Render(HtmlTextWriter output) {

    output.Write("You are here: ");

    for (int i=0; i<this.mCrumbs.Count; i++) {

    HyperLink l = (HyperLink)this.mCrumbs;

    l.RenderControl(output);

    if (i < this.mCrumbs.Count-1)

    output.Write(" >> ");

    }

    }

    }

    }


    --
    Insert corny line here
     
    -=Chris=-, May 22, 2004
    #1
    1. Advertising

  2. -=Chris=-

    Natty Gur Guest

    Natty Gur, May 23, 2004
    #2
    1. Advertising

  3. -=Chris=-

    -=Chris=- Guest

    Thanks. It took a little time to figure it out, since the code changes
    didn't show up right away in the designers I'd already created, but got it
    figured out. Thanks again!

    --
    Insert corny line here
    "Natty Gur" <> wrote in message
    news:...
    > Hi,
    >
    > you need to use some design time attribute. you can read about them on
    > MSDN:
    > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide
    > /html/cpconattributesdesign-timesupport.asp
    >
    > or look at sample code :
    > http://www.asp-files.com/msg/391.html
    >
    > HTH
    >
    > Natty Gur[MVP]
    >
    > blog : http://weblogs.asp.net/ngur
    > Mobile: +972-(0)58-888377
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    -=Chris=-, May 23, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lloyd Dupont
    Replies:
    0
    Views:
    464
    Lloyd Dupont
    Jul 27, 2003
  2. Rene Aichinger
    Replies:
    0
    Views:
    548
    Rene Aichinger
    Dec 7, 2005
  3. Øyvind Isaksen
    Replies:
    1
    Views:
    987
    Øyvind Isaksen
    May 18, 2007
  4. AleXmanFree
    Replies:
    3
    Views:
    578
    Hillbilly
    Oct 9, 2008
  5. Brian Bugge

    Custom Control nad Collection property

    Brian Bugge, Jul 2, 2003, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    164
    Brian Bugge
    Jul 2, 2003
Loading...

Share This Page