Hippo technology inside ASP. NET open-source framework (5)-control structure

Source: Internet
Author: User

5. Control Structure

The previous chapter describes how to implement multi-language design. This chapter describes the Control Section.

Regardless of the backendCodeHow perfect, how perfect, and finally must be presented in a certain form, and to use flexibility, then the control will be used.

In the age of ASP, writing such controls is basically a very painful thing. Now it is much simpler. In Asp.net technology, there are two ways to write controls, one is Web user control, which can adopt Visual Programming, but is not flexible in use, and cannot be compiled into DLL files or own their own parameters, parameters that depend entirely on get/post pages are not suitable for complex scenarios. Another method is to write user-defined components. This method does not involve Visual Programming and relies solely on handwritten code. However, it has many advantages, such as generating DLL, you can load it to the left-side toolbar for calling. You can set parameters and attributes.ProgramAll backend management programs use the latter.

Most of the controls I use are inherited by http://www.infragistics.com/controls. One of the most important controls is the ultrawebgrid control that inherits from it. This control is much better than the grid control that comes with Microsoft and has the effect of winform, the function of the system to inherit it is to add support for metadata and name it dbgridpro. In this class, a function named makestructure is used to initialize the grid. According to the contenttype specified in the constructor, retrieve all attribute (field) corresponding to this type from the database and fill it in the header of dbgridpro. In attribute, the name of the field used for display is specified, the display width and so on are all embodied here. If the field is specified as read-only, the corresponding read-only processing will be performed in the table. If the field is hidden, so it will also be invisible in the grid, so that my dbgridpro will reproduce the contenttype as it is.

In addition to displaying data, the grid control also has an important function to update data. In traditional HTML + ASP operations, generally, it is difficult to update data with the effect of CS. It is easy to write a few text boxes and add a submit button. Now it is much more convenient to have this control, as long as you double-click it in the grid, you can edit the data. Of course, this is entirely because of the original functions of the control that I inherited. Then, you can modify the data of the current row as long as you click any place other than the current row, I have reloaded the updaterow event and added my code to implement this function. These codes are completely encapsulated. When a program calls this control, you only need to specify a contenttype. Because this part of the code is large, it will not be pasted here.

It also has a special control, called the "Dictionary" control, which is also called the seed data in oracleebs. For example, the gender is divided into male and female, and the education level includes primary, middle, and university, organize all the content in two tables. One is zr_dict_category, which stores the dictionary name, such as "gender" and "education level", and the other is zr_dict, which stores the dictionary details, for example, "male", "female", and "Elementary School", a dictionary name, such as dict, is specified for the dictionary control. dictname = "gender". In this way, "male" and "female" are listed in the dictionary control during actual operation, which is convenient, if the dictionary content is expanded in the database, it will be automatically reflected in the control, and no SQL code needs to be written.

In the above cases, all the required dictionary content comes from the same table. In some cases, it is not very convenient. For example, you need to select "user type ", there may be a special table to store it, because the information stored in the dictionary is limited, so the dictionary control cannot be used very well. To solve this problem, there is a special control called "value set" control, which is also learned from oracleebs. Compared with the dictionary control, this control searches for data sources based on a stored SQL statement, such as select user_type_id, user_type from zr_user_type, fill in the corresponding control with the user type ID and name.

The above two controls allow flexible application when using the system.

Now let's continue with the above grid control. In order to implement more expansion and flexibility for it, I wrote a page called content_invoke.aspx, which contains a grid control, the page receiving parameters are used to specify the contenttype, and then the data is captured in the page_load method.

In the winform program, the grid control has rich filtering functions and is easy to use. Just click on the corresponding column, just like excel, you can directly select the desired data, but in IE, it seems that this effect cannot be achieved. Therefore, different systems have different practices for record screening, the general practice is to make a lot of text boxes for different condition input, or create a drop-down list to enter different conditions, but it is generally difficult to achieve a combination of complex conditions. The filter control I made is also bound to content. It will read all the attributes of contenttype as the filter condition and check its field type, to determine the controls used to receive the input value, such as date or numeric. For a field, there are two conditions, which can be connected by and or in the middle, after the SQL statement is assembled, a complex SQL condition is formed, and it is appended to the end of the query statement to implement query by conditions. This control is used together with dbgridpro on the content_invoke.aspx page.

In the "meta-data driver" chapter, we once mentioned the concept of "sub-table", which is also reflected in content_invoke.aspx. The program divides this page into the upper and lower parts, it is used to display the body content of contenttype. All Sub-tables are displayed in the following section. If multiple sub-tables exist, they are displayed in different tabs, in fact, we also put a dbgridpro to display the relationship, and finally there is a one-to-many relationship after the Assembly. This relationship is especially suitable for describing the relationship between the order header and the order line in the order. Generally, each order corresponds to several order lines, and the payable details, delivery details, and other information can also be found.

In the winform program, there are two types: one is the SDI mode, the other is the MDI mode, the SDI is called a single form, and the MDI is called a multi-form. The typical application of SDI is notepad, after opening a file, the previous file will no longer exist, and the typical application of MDI is word. You can open multiple files for editing at the same time without affecting each other.

In HTML, there are two methods to connect. One is to directly replace the content of the previous page, and the other is to open it in a new window, it can be understood that it corresponds to SDI and MDI In the CS program, but it is difficult to open several pages in the same ie window. I have made a lot of effort for this function, finally, some basic controls are added to achieve the real MDI effect. This effect can be found in Yahoo Mail.

To better reflect the controls, you must rely on a good data structure in the background. It is in the meta-data drive mode that these controls can be used with ease, form a well-scalable background management part. The next chapter describes how to use the background and expand the Background Management Section.

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.