Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > INamingContainer problem...can I work around this?

Reply
Thread Tools

INamingContainer problem...can I work around this?

 
 
R. Myers
Guest
Posts: n/a
 
      11-27-2004
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?



 
Reply With Quote
 
 
 
 
R. Myers
Guest
Posts: n/a
 
      11-27-2004
"R. Myers" <(E-Mail Removed)> wrote in message news:<Yx1qd.19$(E-Mail Removed)>...
> 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[i]);
}

m_Table.RenderControl(output);
}

This works. If I'm missing anything please let me know.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: ASCX without INamingContainer Natan ASP .Net 5 08-29-2006 02:03 AM
What does the INamingContainer Inteface do? gemel ASP .Net 3 01-06-2005 03:24 PM
INamingContainer has change my controls event order..... Alex Stevens ASP .Net 0 10-19-2004 05:02 PM
INamingContainer and the LinkButton... Jo Inferis ASP .Net 1 05-27-2004 01:43 AM
Re: problem with INamingContainer SatinderGT ASP .Net 1 06-27-2003 01:21 PM



Advertisments