Let me quote from an article I recently wrote: Take Control Of Web Control ClientID Values in ASP.NET 4
Each server-side Web control in an
ASP.NET Web Forms application has an
ID property that identifies the Web
control and is the name by which the
Web control is accessed in the
code-behind class. When rendered into
HTML, the Web control turns its
server-side ID value into a
client-side id attribute. Ideally,
there would be a one-to-one
correspondence between the value of
the server-side ID property and the
generated client-side id, but in
reality things aren't so simple. By
default, the rendered client-side id
is formed by taking the Web control's
ID property and prefixed it with the
ID properties of its naming
containers. In short, a Web control
with an ID of txtName can get rendered
into an HTML element with a
client-side id like
ctl00_MainContent_txtName.
This default translation from the
server-side ID property value to the
rendered client-side id attribute can
introduce challenges when trying to
access an HTML element via JavaScript,
which is typically done by id, as the
page developer building the web page
and writing the JavaScript does not
know what the id value of the rendered
Web control will be at design time.
The Web control's client-side id value can be determined at runtime via the Web control's ClientID property. This is why others have suggested using <%=Menu1.ClientID%> in place of a hard-coded id name.
If you are using ASP.NET 4.0 you have more control over how Web controls render their ID property into a client-side id via the Client. Namely, you can set the Menu's ClientIDMode property to Static to ensure that there is a one-to-one correspondence between the server-side ID property and the client-side id attribute (but you must be careful using this approach).
For more information refer to:
Happy Programming!