Home All Groups Group Topic Archive Search About

Maintaining "id" attribute value in server controls

Author
27 Nov 2005 11:47 AM
markarichman
Because of my CSS selectors, I need to maintain the "id" attribute's
value for a server control. The control is as follows:

<%@ Control Language="C#" AutoEventWireup="true"
CodeFile="NavControl.ascx.cs" Inherits="NavControl" %>
<ul id="nav" runat="server">
    <li>...</li>
    <li>...</li>
    <li>...</li>
</ul>

Upon rendering, the value of <ul id="nav"> becomes <ul
id="ctl00_NavControl1_nav">. Setting nav.ID in code-behind has no
effect. How do I maintain the value of the "id" attribute in the
browser so my CSS works?

Author
29 Nov 2005 5:40 AM
Shane
I don't have the specific answer for you, but I have had to use the
"ClientID" property recently to write some javascript at the server and
access a server based control.

Show quoteHide quote
"markarich***@gmail.com" wrote:

> Because of my CSS selectors, I need to maintain the "id" attribute's
> value for a server control. The control is as follows:
>
> <%@ Control Language="C#" AutoEventWireup="true"
> CodeFile="NavControl.ascx.cs" Inherits="NavControl" %>
> <ul id="nav" runat="server">
>     <li>...</li>
>     <li>...</li>
>     <li>...</li>
> </ul>
>
> Upon rendering, the value of <ul id="nav"> becomes <ul
> id="ctl00_NavControl1_nav">. Setting nav.ID in code-behind has no
> effect. How do I maintain the value of the "id" attribute in the
> browser so my CSS works?
>
>