Scalable MasterPage solution

xiaoxiao2021-04-01  214

Preface:

I have had some research on the object model of ASP.NET Framework and ASP.NET Page, and some interesting technologies in ASP.NET have some research, such as MasterPage technology. When discussing how WebForm's unified page is schema, there are two optional options:

1. The first program is the most original solution. In each business form (ASPX), in addition to the masterpage that contains yourself, it will contain Topbanner, LeftBanner, Bottombanner. The disadvantage of this solution I will not mention it here.

2. The second solution is to provide a Unified Page Template: Default.aspx, which contains Topbanner, LeftBanner, MasterPage, Bottombanner total, where MasterPage is dynamically variable. All of the user's page request turns to the Default.aspx page, and PageId is added in the querystring of the URL. When the request is in response to each request of the customer, DEFAULT.ASPX reads the value of PageID, according to different PageId, according to different PageId, according to different PageId, depending on the configuration. Although this approach solves the problems in the programs, it is a very awkward process for customers or developers: I need to turn to MasterPage. Its benefits and disadvantages are obvious.

???

Can there be a way to define a unified style page template, and implement each of the business-related forms (not including a public HTML module); and presentation when the browser requests each business form, rendering That unified style page template, and in this template's Master area embedded your own business form? There are many ways to solve this problem in ASP.NET1.1, in which the mature scheme is MasterPage technology! And how this technology has been provided in Aspt.net 2.0 (how to implement aspt.net2.0) I have not studied. The following research is the technology under ASP.NET1.1).

MasterPage Technical Idea:

The so-called MASTERPAGE technology is to provide a page template, which can be designed a unified template based on specific needs, such as Topbanner, LeftBanner, part of the Bottombanner section, as shown below:

The various business forms of the developers do not contain any Topbanner, LeftBanner, Bottombanne section, with only the business-related UI content. As shown below:

When the browser requests each individual business form, each form does not only present its own content, which will first present the page template, let the work-related UI content into the masterpage area of ​​the page template (yellow area ).

MasterPage specific implementation technology:

About how to implement MasterPage Technology on the Internet by many implementations. More than a few examples are: http://www.codeproject.com/aspnet/frame_work_design.asp on www.codeproject.com

Www.cnblogs.cn http://mack.cnblogs.com/archive/2005/06/18/176869.html

Among them, WWW.CNBLOGS.CN design is an improvement plan for www.codeproject.com. Here I will find out about their technical points: 1. First of all, they have developed a WebControl inherited HTMLFORM, I am here to call MasterPageform

2. In each business form page, use this masterpageform instead of HTMLFORM, that is, when the original ASPX page is:

Specific content

After the change, it became such a situation:

Specific content

3. When the masterpageform is instantiated, the masterpageform is executed, and the page template (actually an ASCX) is used, and the page template ascx is the first one of HTMLFORM. Sub-control, simultaneously move controls in all design periods in the business form to the masterpage (yellow) location in the page template ASCX (specific to implement: In the page template ASCX, add a PlaceHolder control as an anchor of MasterPage Location, MasterPageForm After loading the page template ASCX, Moved Pointholder Controls will be found, move the controls in all the design periods in the business form to this PlaceHolder)

4. Pass the third step, the actual business form is equivalent to having a page template and has moved the controlled the original itself to the hope.

5. This is the result that is the result of the final actual presence to the browser.

Evaluation MasterPage Implementation Technology

MASTERPAGE is more complicated and implements multiple webcontrol. This is a unclear obstacle to the user, and in each specific business form page, you must use the custom masterpageform to include content, it is not Very cleaning practice. That is to say, the dependence of WebControl is too high, and intuitive, controllability, self-expandability is not high!

For example, the original business face form is like this:

label

After applying MasterPage technology, becomes as follows:

label

Implement an intuitive, simple, easy to expand, easy to control

There is no way to the end, you can use the benefits of masterpage technology as described above, and don't want to be bound by them? The answer is yes, let me briefly introduce this intuitive simple implementation!

My program is to stand on the existing masterpage, take the essence, go to the product after it! In fact, the amount of MasterPage's implementation method is: masterpageform. Since he is a cumbersome, then I simply put him!

After that, how do you load the page template ASCX? Very simple, I have to integrate each business form, by this pagebase to be responsible for the page template ASCX. PageBase is also responsible for moving the business form page to the page template ASCX PLACEHOLDER. This process is more clear as follows:

Structure map of design

Runtime structure diagram

I have provided a DEMO (see an attachment, after decompression, send the ASPNetTry directory as a web sharing), you can decompress the local and research MasterPage Technology. I mainly introduce the content of the compressed package.

PageBase.cs refers to all public base classes of all business forms

PageTemplate.ascx refers to the specific page template ASCX (with two PlaceHolder: MasterPlaceholder and ToprightPlaceholder)

PageTempleteInterface.cs is an excuse class that is provided to PageBase calls, which defines many interface functions that insert controls into the PlaceHolder throw. Each PageTemplate.ascx must implement this interface

The first page class of WebForm1.aspx will move itself to the masterplaceholder of PageTemplate.ascx.

WebForm2.aspx second page class, in addition to moving their own PanelToPright to the TOPRIGHTPLACEHOLDER of PageTemplate.ascx, the remaining business-related design period control is moved to the masterplaceHolder of PageTemplate.ascx.

In addition, WebForm1.aspx, WebForm2.aspx also supports buttom's Submit Submit, JavaScript script, viewState processing. See the code for details. According to some Javescript, viewstate, button event processing in demo / files / caomao / aspnettry.rar, there will be no problems, I believe in other problems during the period, and I will share it with you in time! Welcome everyone to make improvements, let this masterpage use it better, I think this masterpage can bring great convenience when developing ASP.NET 1.1 web projects.

Thanks!

Http://caomao.cnblogs.com/archive/2005/12/09/293591.html

转载请注明原文地址:https://www.9cbs.com/read-131274.html

New Post(0)