Before writing CSS about the article, I wanted to write how to use the ASP.net control can be more CSS friendly, easier to implement some common page layout pattern, but later found that this is not so easy. It's easy to say that to make the ASP.net control css friendly, it's easier to use ASP.net 2.0 CSS friendly controls adapters, but the fact is not so simple.
The lack of CSS friendly control adapters
First, allow me to complain about this CSS friendly control adapters. The first I saw it output the class name I feel very faint, give some examples: Aspnet-menu, Aspnet-menu-withchildren, Aspnet-menu-leaf. If you are accustomed to the client code all use camel nomenclature, you can see that the name will not be appropriate, you want to change the original naming method to accommodate these controls? Or do you want to make a variety of naming laws in your CSS file? What if you need to change these default class names? Sorry, the CssClass property of the control itself has no effect, because the HTML structure of the control output changes, and those cssclass no longer correspond to which HTML element. Therefore, if you need to change these class names, the only way is to change the ControlAdapter source code directly, and class naming is hard-coded in the source code as a string, even if you use search to replace you are afraid to replace more or less to introduce more trouble.
When it comes to source code, the second problem with these controladapter is that the site must carry all their source code, not just compiled DLLs, but that the source code is not modifiable. Why is it that the modification is not strong? If you have ever thought about writing some controladapter yourself, I think you have consulted the existing controladapter, and you will find that writing ControlAdapter relies heavily on your understanding of the control itself, Not only the understanding of the public part of control, but also the deep understanding of the inherent logic of control. Therefore, either you are the author of control, or you have a closer look at the source code of control, it is impossible to write controladapter, or even modify the existing is difficult.
Therefore, CSS friendly control adapters is a very good choice, so we might as well look ahead and see what Microsoft has to offer us in asp.net 3.5.
ListView and New TemplateControl forms.
If you are familiar with the Sys.UI.Data.ListView previously provided by Atlas, you will feel that these two ListView are very similar. Unlike previous templatecontrol (such as the GridView), ListView no longer directly output the container's own code, but provides a template to your custom container, where you can freely write your container code in this template, It can be
, or it can be
or
. After the template of the project is also allowed to customize, the corresponding
nature is , and the corresponding
and
should be
. Because these are the HTML code that you write manually, you can set the class attribute to allow you to maintain a consistent naming style throughout the site.
The submission of Web form?
When ASP evolved to ASP.net, the support of drag-and-drop controls like win form became the biggest feature, but now the Web form is written back to the other server-side scripting languages, such as VBScript. Before the ASP time, not just write the container of their own HTML, and then use <%for ... next%> the project HTML circle, now called template is actually no difference Ah! Moreover, other server-side scripting languages have similar wording, but they may be the helper function or any other salutation.
As a result, it turns out that unless you give up control of HTML details (which is hard to do with CSS friendly), the way to declare a data representation template is similar for most server-side languages, and there is no more convenient way to do it. The easy way is to access the data, from ADO to Ado.net, from the typed dataset to the LINQ to SQL. It's hard to say whether Microsoft will release more similar templatecontrol in the future, because ListView is already very customizable, and DataControl used to represent data structures in two-dimensional tables can be used as a substitute, The same field of control has no meaning, unlike before to separate a few DataControl. I think it's best to see a CSS friendly control that replaces menu, because the data structure that menu behaves is not a two-dimensional table, but a tree, and it is necessary to provide the data structure with an accurate declaration of HTML details.