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 for each control i have defined class and id. The problem i am facing is that when i apply style to a particular control using the class , the styles are reflected properly, and when i do that using the id of the control the style is not reflected.
I rectified the issue but i dont know how to solve that.
For instance,
I have a textbox with id="txtCustNo" ,, when i apply style like
#txtCustNo{border:1px solid red}
it doesnot reflect ,,,when i apply style like #ctl00_ContentPlaceHolder1_txtCustNo it shows the changes , however the id is txtCustNo..Can somebody point me out where am i going wrong.Thanks .
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