Introduction to the use of asp.net 2.0 new controls

Source: Internet
Author: User
Tags dreamweaver microsoft website
New. NET 2.0 controls and their usage.

I. Data Source Controls

SqlDataSource: A child-type data source. It is just like a data dictionary class, but you only need to set some of its attributes to work, it works well with other data display controls. Therefore, it is very convenient. If VS doesn't know how to use this stuff, you can go to kindergarten for further study.

ObjectDataSource: an enterprise-level solution that eliminates the need to worry about the UI Layer. If you are using a database-based application. You can easily bind your data access layer or business layer to this cute thing. It is as convenient as the children's toys above. Mary cares.

XmlDataSource and SiteMapDataSource can also be bound to XML files or site maps (as mentioned later, the default format is also XML). You can also select them using XPath or directly convert XML using XSLT (XmlDataSource)

I forgot another child toy, AcceseDataSource. Don't underestimate children's toys, Doraemon...

Ii. New Data Bound Controls

GridView: a new table-type data control that replaces the DataGrid. In fact, no DataGrid is available on the toolbar of VS2005 by default, and it may be self-satisfied. To put it simply, the GridView is a silly DataGrid, and you don't have to write a lot of code for a simple paging or other functions. A property is flat. And its columns are richer. In order to distinguish the Column attribute of the DataGrid, its columns are all called Field. I really don't know what will be called in 3.0 in case of new requirements?

DetailsView: If you maintain a data table, you can easily write additional and personalized pages and write a lot of boring code. Now DetailsView is a good solution. It is finally liberated. DetailsView is a record data control that can be added, modified, or paged.

FormView: You can use it as the custom version of DetailsView, which is described in the following binding.

Iii. Data Controls Parameter

That is, the above Data Source parameters. If there are multiple types of parameters, we will not explain them one by one. We will only list them. If Data Source and Data Bound Controls are used together, the parameter name is limited. Parameter (static); QueryStringParameter; ControlParameter; SessionParameter; FormParameter; CookieParameter; ProfileParameter.

4. Improved Data Binding Syntax

New binding method <% # Eval (...) %> and <% # Bind (...) %>, no more iner is required. dataItem, because the two methods can only be used in the container bound to the data. Bind is a two-way binding, which can be Bound from the Data Source to the Data Bound Control, and can be returned from the Data display Control to the Data Source Control.

V. Vertical controls

That is, the new controls TreeView and Menu are like the Menu on the Microsoft website. TreeView is the tree-like method of MSDN. In fact, TreeView can also implement block reading like MSDN, but there is no actual test, and I don't know if it can be applied to various browsers, but TreeView is no longer the poor product that Microsoft provided in the 1.1 s.

2.0 of Data Binding completely changed the mode. Of course, it is still backward compatible, but I think the new method may indeed bring us quite convenience.

 

N long ago, I also saw this statement on the CSDN Forum: ASP. NET client verification is insecure. However, the verification control is verified on the server, regardless of whether the client has been verified. In Firefox, all the verification tasks are performed on the server.

Because 1. the validation controls of Version x are implemented using HTML Custom Attributes. These features are not supported except for IE and IE kernel browsers. Therefore, when verifying the data of other browsers, you can only return to the server in any case. In 2.0, this feature was finally modified, although it looks silly. Yes, it does add attributes to the span element generated by the verification control using javascript, just as we would expect in javascript. However, such a simple change greatly increases the number of browsers that can be verified by the client (basically ).

The ClientTarget attribute of Page allows you to set whether all verification controls are verified on the client. You only need to set this attribute to UpLevel. Under DownLevel, all the verification tasks will only be executed on the server. By default, most browsers are verified on the client, so I don't know if this attribute is UpLevel by default. Of course, if you want to set one or more verification controls separately, use the original EnableClientScript.

In addition, a SetFoucsOnError attribute is added. That is, when an error occurs, move the focus to the control. In this way, the user will not be stunned after clicking the button because the error message is not displayed. Another small thing is that valimvalidator adds the ValidateEmptyText attribute to allow the custom verification control to verify when the value is empty.

The next useful feature is the ValidationGroup attribute. Set the control you want to verify when you click a button to the same group name, and set another button to verify to another name, in this way, only the expected verification occurs when you click a button, instead of all the verification, instead of displaying the control on the server side. Note: The ValidationGroup attribute should also be designed for buttons.

The last one is that the comparison validation control will use a culture-independent format.

The usage of the verification control has not changed much.

The style of Window XP was finally moved to ASP. NET by the cute M $. This reminds me of the horrible idea of M $. 150 IQ is now broken down. 150 IQ = Microsoft solution + 50 IQ + has learned to tolerate imperfections and mistakes. Of course, if your IQ is already 150 LEVEL, using Microsoft solutions may cause overflow. (Not in scope)

In fact, words such as styles and themes cannot properly describe these things in ASP. NET 2.0. Because it is easy to confuse with css of our webpage style sheet. In fact, you can define more than CSS styles in themes and skins. The style of the server in QuickStart is more appropriate. Most of the theme and skin content can be defined, excluding Id.

All themes and skins must be placed in a directory named App_Themes, which can be application-level (put it under your site directory) or global (put it in.. net directory, or put it in a directory of IIS. For more information, see help ). A topic is actually a collection of multiple skins. The subdirectory name under App_Themes is the topic name. The file whose suffix is. skin Under the topic name is the skin file.

The method of skin files is even dumb. In fact, it is to move the attributes originally written under the control to. skin. The writing method is basically the same as that of the .html x file, but there is no Id attribute, but there is an additional SkinId attribute. You can use the style defined by this skin with the same SkinId on the page. The control that does not use the SkinId attribute in the skin file will be applied to the similar control that does not specify the SkinId in the page by default.

Sorry, I forgot to display the specified Theme attribute in the Page instruction or program code. The attribute value is the name of the sub-folder under App_Themes. There is also a StyleSheetTheme attribute, which is also the same value range. Dizzy? Theme Properties> properties specified on the page> attributes specified in StyleSheetTheme properties. However, the above statement is obviously true in the example.

I don't know whether my uncle, big brother, and big sister have considered this. What should I do when there are N drop-down boxes such as male and female on a website? Write its ListItem on each page? BIND database or XML? A long life disappears in this kind of thinking? If this is the case, you should start to like the skin. You can put the content of your simple data selection box in the skin file.

Data Binding expressions can even appear in skin files! Of course, this is very limited, only in the data display controls, such as DataList, DataGrid, Repeater, GridView, etc. (VS2005 toolbar they are placed in a separate group ). The new Eval or Bind expression must be used and cannot be bound in the skin.

CSS, images, and other resources can also be used in skin files. You don't have to worry about path issues. M $ has already helped us solve them. Of course, CSS should be used carefully because it can affect the global situation.

Finally, if you want to use the same topic for the entire site, specify it in Web. Config. Add this kind of stuff <pages theme = "ExampleTheme"/> under System. Web. You can also specify the topic in the code, but it is not in Page_PreInit or Page_Load.

Poor, I am fighting against the heartless sleep magic during my two-day training at the company. It is not easy to take the time to write study notes. Thank you for your patience, thanks!

First of all, because this article is very small, it is mostly nonsense. By the way, if you have time to read the notes of idle people like me and give them a detailed explanation, or even read the computer newspaper, you might as well have time to do what Uncle should do. I am not only hypocritical, but do not like any meaningful or meaningless criticism. Just For Fun! No Class!

CSDN does not know that it is to strongly prove the robustness of Microsoft's SQL SERVER. Every night, it always shows us countless times of exception prompts when the connection pool is full. In order to delete the sequentions of F5 after N times of posting the previous article, I deleted the redundant article again in NF5.

The topic and style are mentioned last time, but this time we will mention the Master Page (which is called the parent Page or the home Page, which is not very clear, so the original English word is used) is also ASP. NET 2.0 is one of the improvements to WEB features. I feel that 2.0 has introduced common WEB features to the server. The Master Page is designed like a server framework.

Both include and ASP. NET user controls starting with ASP are a solution for the public part of the page. The Master Page introduced by 2.0 gives a better choice.

In fact, the Master Page is more like a Dreamweaver template, but it does not actually exist. Unlike Dreamweaver, it only exists during design. The Master Page defines a framework for a site of the common style, and uses placeholders inside it to represent the parts that can be actually modified. The syntax is as follows.

In the Page declaration, the Master command replaces the Page command, for example, <% @ Master Language = "C #" %>. The syntax in the Master Page is not much different from that in a common Page, but there is a placeholder control. For example, <asp: contentplaceholder id = "FlowerText" runat = "server"/>. The content in the placeholder is its default content. If no new definition is provided for the placeholder in the ASPX Page using this Master Page, it will display its default content. To distinguish it from a common Page, the Master Page ends with a suffix. master.

To use Master Page on a Page, specify the Master Page path in the MasterPageFile attribute in the Page declaration. You can define placeholders to display different effects on the page. Syntax ):

<Asp: content id = "Content1" contentplaceholderid = "FlowerText" runat = "server">
With sunshine, water, and careful tending, roses will bloom several times in a season.
</Asp: content>

In fact, if the Master Page is referenced in the Page, only the content corresponding to the placeholder can be defined. What about the titles of different files? In the Page command. A Title attribute specifies the Title of each page.

The Master Page does not solve the problem of the relative path of the link. Unfortunately, we still have to use the absolute path or application-related path (ASP. NET-specific ~) Solve the Path Problem for references in different paths.

To call and modify the content of the Master Page in the code, add the following command to the Page: <% @ MasterType VirtualPath = "Site. master" %>. You can use the Master in the code to call the content in the Master. There are two methods to call here: Providing properties in a strong type or directly operating the controls in the Master Page.

The Master Page can be nested, so you can easily create a general framework for a site and create a more detailed framework for each part.
The syntax for referencing another Master Page in one Master Page is the same as that of Page. Therefore, it can only contain something like asp: content.

I have been absent from practice in recent studies, but it's nothing for me (adjectives are omitted about 500 words. If you have any new ideas after practice, write new notes.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.