INamingContainer problem...can I work around this?

Discussion in 'ASP .Net Web Controls' started by R. Myers, Nov 27, 2004.

  1. R. Myers

    R. Myers Guest

    I have implemented INamingContainer in a custom WebControl. It provides
    unique ID's for controls without ID's. However, if my control already has
    an ID set in its property panel, or in code, The HTML that is rendered
    always shows the unique ID in front of it.

    If the ID is "Table1", it renders as _ct10_Table1". Is there any way to get
    the ID to be exactly as provided, and only supply the unique ID's for
    controls without ID's?
    R. Myers, Nov 27, 2004
    #1
    1. Advertising

  2. R. Myers

    R. Myers Guest

    "R. Myers" <> wrote in message news:<Yx1qd.19$>...
    > I have implemented INamingContainer in a custom WebControl. It provides
    > unique ID's for controls without ID's. However, if my control already has
    > an ID set in its property panel, or in code, The HTML that is rendered
    > always shows the unique ID in front of it.
    >
    > If the ID is "Table1", it renders as _ct10_Table1". Is there any way to get
    > the ID to be exactly as provided, and only supply the unique ID's for
    > controls without ID's?


    O.K. I think I got it now. I misunderstood the use of
    CreateChildControls. If I understand it correctly, I can add any
    number of objects of various types to the Controls collection just to
    get a unique name. Then when I render the control, I can reference
    each object in the controls collection by index, and render them as
    needed. They don't all need to be of the same type.

    For example, I can add a TableRow, and 5 TableCell's to my control.
    Then I can render as follows:

    protected override void Render(HtmlTextWriter output)
    {
    m_Table.Rows.Add((TableRow)this.Controls[0]);

    for (int i = 1; i < this.Controls.Count; i++)
    {
    m_Table.Rows[0].Cells.Add((TableCell)this.Controls);
    }

    m_Table.RenderControl(output);
    }

    This works. If I'm missing anything please let me know.
    R. Myers, Nov 27, 2004
    #2
    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. SatinderGT

    Re: problem with INamingContainer

    SatinderGT, Jun 25, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    1,306
    William F. Robertson, Jr.
    Jun 27, 2003
  2. Piet
    Replies:
    0
    Views:
    518
  3. sal_scozzari

    ClientID INamingContainer problem

    sal_scozzari, Nov 8, 2007, in forum: .NET
    Replies:
    0
    Views:
    479
    sal_scozzari
    Nov 8, 2007
  4. Network/Software Buyer
    Replies:
    0
    Views:
    412
    Network/Software Buyer
    May 23, 2010
  5. Sergio FLorez M.

    Problem with INamingContainer

    Sergio FLorez M., Jun 20, 2005, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    129
    Sergio FLorez M.
    Jun 20, 2005
Loading...

Share This Page