I am using asp.net/C#
for my project.Currently i have a default.aspx
page and a master page.The default.aspx
page has many controls , and
The client ID is not equal to the ID property of a runat="server"
control. To get the ID on the client, you can use the ClientID property.
On newer ASP.NET versions (starting with version 4), there is also a ClientIDMode property to control the generation.
So to solve your issue, you could either set ClientIDMode
to ClientIDMode.Static
or somehow access the ClientID
property from code behind and put this value into your CSS definition.
Alternatively you could also:
div
) that has no runat="server"
and put an ID into this container control, changing your CSS to e.g. #txtContainer input{border:1px solid red}
The ID on server controls is automatically generated and is not the same as the generated ID on the client side.
You can find what the generated ID with be with this: <%# txtCustNo.ClientID %>
ASP.NET 4 supports a new ClientIDMode property on the Control base class. The ClientIDMode property indicates how controls should generate client ID values when they render. The ClientIDMode property supports four possible values:
When using ASP.Net before 4.0 you have to live with the auto generated ID's.
For more info on the 4.0 features see this link.
http://weblogs.asp.net/scottgu/archive/2010/03/30/cleaner-html-markup-with-asp-net-4-web-forms-client-ids-vs-2010-and-net-4-0-series.aspx
ClientIDMode="Static"
Also, if you are trying to style a control via CSS, just wrap a div around it & then apply styles like (these get applied to all inputs inside that div)
divId input {
width: 100px; }
ASP.NET Themes and Skins Themes & Skins