ClientId is a virtual method, so you can override it when deriving your
own control. You have to beware of name-colissions though.

Paul

-----Original Message-----
From: Discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] On Behalf Of Paul Cowan
Sent: Tuesday, May 30, 2006 14:19
To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM
Subject: [ADVANCED-DOTNET] Controlling ClientID - ASP.NET 2.0

Hi all,
I have a problem with the clientIds that ASP.NET is omitting.  Consider
the following code:
 
HtmlGenericControl listControl = new HtmlGenericControl("ul");
listControl.ID = menu.Name;
foreach (Node node in menu.Nodes)
{
if (node.ViewAllowed(this.CuyahogaUser))
{

HtmlGenericControl listItem = new HtmlGenericControl("li");
HyperLink hpl = new HyperLink();
hpl.NavigateUrl = UrlHelper.GetUrlFromNode(node);
UrlHelper.SetHyperLinkTarget(hpl, node);
hpl.Text = node.Title;
listItem.Controls.Add(hpl);
listControl.Controls.Add(listItem);
if (node.Id == this.ActiveNode.Id)
{
hpl.CssClass = "selected";
}
}
}
In the line listControl.ID = menu.Name;, the framework prefixes the
menu.Name with p_ and every hyperlink has the same problem if I give it
an id.
The problem is that the positioning and imaging is tightly controlled by
.css files.  I know I could change the .css but I would rather have
control of the ClientId I render.  The ClientId property of the Control
class is readonly.
Is there a way round this problem?
 
Thanks
Paul

 
===================================
This list is hosted by DevelopMentor(r)  http://www.develop.com

View archives and manage your subscription(s) at
http://discuss.develop.com

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to