Sharepiont Page Model

Source: Internet
Author: User
This article mainly includes the following aspects:

1. Page Layout and master page
2. Page Layout Model
3. Page Model
4. field controls and control templates
5. Page Processing Model

1. Page Layout and master page

The master page and page layout are the two most basic template models in moss2007. The master page and page layout form any page you can see on the SharePoint website. The master page contains many controls, such as navigation bar, search, or site map. The page layout includes field controls and Web parts. The following figure shows how the page layout and master page are applied to the creation of a page layout:



All master pages and page la s are stored in this document library, which is the "master pages and page la s" in the website. This Library supports version control and workflow. By default, every website shares the master page library created by moss2007. You can only create a new page by using the page layout in the master page library of the top-level website. In addition, the layout of all pages on the website is attached to a master page, which is set based on the "mmmmasterurl" attribute of the spweb class of the website. All page la s share some controls called field controls, which are bound to the related fields of the list items on the master page. You can use the default control or build your own. The field control allows you to edit and display the page content.

The page layout can be used by all page instances created based on the page layout. The master page can be used by all pages on the website. Different masters can be used on different websites for all page instances based on one page layout. When you use SPD to edit a webpage, the following prompt appears. You cannot use SPD to edit a webpage. You can only edit its webpage layout or its corresponding master page.

 

Content type:Content type: content type is used in Sharepoint Server to define the page type, such as "news page" and "plain text content page. By defining a group of columns, it determines what information can be displayed on a page.
Page layouts:Page Layout: defines how the page displays information. Each page layouts uses a master page and is associated with a content type. In this way, each page layouts can define how to display the information defined in the content type on the page, that is, where the information in each column in content type is displayed on the page. Generally, we place some field control on the page layouts, and each field control corresponds to a column.
Page:Page, in fact, the page in Sharepoint Server is not a real page file. When we create a new page, we will choose which content type page to create. Then, sharePoint will let us select one from a page layouts (of course, the page layouts available here must be associated with this content type), and finally, by entering the column value defined in content type, a page is created. Each page is just a listitem saved in the pages list.

Page output steps:
1. the user requests to access a page from the client.
2. SharePoint finds the listitem corresponding to the request page from the pages list.
3. According to the value in the corresponding column of the listitem, Sharepoint finds the associated page layouts and obtains the information on the page layouts.
4. According to the definition of page layouts, obtain the information of the master page used by the user.
5. Run the page.
6. Field Control on the page retrieves the value from the corresponding column of the listitem corresponding to the page and displays it in field control.

2. Page Layout Model

Page layout is used to connect the master page and page, and control the appearance, visual effect, and content of the page. It is also a template model. Each page layout has a related content type, which defines the content that can be stored in the page layout created based on the content type. Moss 2007 provides three default release content types: page,ArticlePage and welcome page.

Each content type contains several "columns" that define elements used to display tags on pages and metadata pages. The content type also contains a special column that defines the display mode for each data element. When creating a content type, you can add a specific column to each of your desired controls. The bar template determines the default field control associated with this column, for example, a single row text box, a hyperlink or an image.

The page content is stored as a list item in the SharePoint "page" document library. When the user opens or edits this page, the content will be pulled out of the Sharepoint list and displayed in the field control. When creating a page layout, you can add a field control by using the page layout editor, such as Microsoft Office Sharepoint designer 2007 or manual editing. The built-in page content types include the columns (fields) that describe the page metadata. For details about these columns (fields), see the following table:

column description
scheduled start date date on which the page is displayed on the website
planned end date the date on which the page is not displayed on the website
contact users or user groups created on the page
contact email address email address of the creator of the page
contact name name of the creator of the page
Contact Image Create a person's photo on the page
page layout defines the page layout of the application when the page is created
displayed in the navigation bar If the page is displayed in the navigation bar, set yes; otherwise, set no



A page layout can be shared by all pages created based on it. A master can be used by all pages of a website. You can apply different masters to different pages under different websites while applying the same page layout. Just like using other document libraries in Sharepoint, you can use version control, check-in and checkout, workflows, and any other features on the page layout, which are also applicable to master pages. To ensure the security of the master page library, users with design or higher permissions are not allowed to operate on it. You can create folders in the repository to better organize your own master pages, so that you can apply the new "project-level permissions" feature of moss 2007 to set the permissions for this folder separately.

3. Page Model

Although moss2007 uses ASP. NET 2.0 basic page model, Sharepoint pages are basically built based on the standard aspx technology, but the moss2007 page model is still more common than ASP. NET applications are much more complicated. For a Sharepoint developer (and designer), it is very important to understand the SharePoint page model.

In SharePoint 2007, there are two types of pages: Application page and Site Page. Application page refers to a Sharepoint application.Program Page used. For example, when we enter the site settings of a Sharepoint site, almost all site settings pages are application pages. If we see that the page paths in the address bar are similar to "http: // sharepointsite/_ layouts/xxx. the format of aspx, that is, the page is located in the "_ layouts" virtual directory, then this page is applicatoin page. The application page is physically stored in the "Program Files \ common files \ microsoft shared \ Web Server Extensions \ 12 \ template \ layouts" directory of the SharePoint Web Front-End Server, it cannot be customized by users. Site Page refers to a common page located in a Sharepoint site. For example, the homepage of the site is "http: // your pointsite/default. aspx ", or the page in a document library:" http: // your pointsite/pages/xxx. aspx ", all are site pages.

The application page is actually no different from a common ASP. NET page. If necessary, developers can add new application pages by themselves, you can add a new page in the "Program Files \ common files \ microsoft shared \ Web Server Extensions \ 12 \ template \ layouts" directory, you can also create a new sub-directory (or virtual directory) in this directory to place your application page. In application page, developers can directly add in-line code based on their own needs. These codes will be executed directly, just like a common ASP.. Net Applications (of course, application page is also supported for the code-behind mode ). For example:
<SCRIPT runat = "server">
Protected void page_load (Object sender, eventargs E)
{
// Code ...
}
</SCRIPT>

For application page, Sharepoint 2007 always regards them as secure, because neither the site administrator (non-server administrator) nor the user can directly modify the application page, sharePoint 2007 will directly "execute" them.
If you want to create your own application page, try to follow this mode:
1. Let your application page inherit from "Microsoft. Sharepoint. webcontrols. layoutspagebase;
2. Let your application page use the master page "application. Master" located in the layouts directory;
3. Create a New subdirectory (or virtual directory) in the layouts directory to put your application page. Do not mix it with the application page that comes with Sharepoint.

Site Page is more complex than application page. For Site pages, we usually divide site pages into uncustomized pages and customized pages based on whether they have been customized (via SharePoint designer 2007. (In sps2003, ghosted page and unghosted page are used .)

When we create a new site, all the pages are uncustomized pages, these pages directly use the Page Templates stored on the SharePoint Web Front-end server disk (in each subdirectory of "Program Files \ common files \ microsoft shared \ Web Server Extensions \ 12 \ template ") ), in other words, the pages of this new site are actually "nonexistent" and they are just a "tag" (that is why they are called ghosted pages in sps2003 ), if you access a page, Sharepoint will automatically find the real page template file from the disk, load it into the memory, and parse it, and compile it into an independent DLL file (for performance, this dll will be cached on the disk to avoid repeated compilation next time), then load the DLL, run, and output.

However, if the site designer uses SharePoint designer 2007 to open the SharePoint site, and then uses SharePoint designer to open a site page file, make some modifications and save the changes, sharePoint automatically saves the modified file content to the content database used by the site, which becomes a customized page. Since then, this customized page is "out of relationship" with the page template on the disk. When a user accesses this page, Sharepoint will automatically read the content of this file from the content database, and then parse and run it. Note! This time, Sharepoint will no longer compile it into an independent DLL file. In fact, Sharepoint will load the structure of this page in the memory, run it, and then output it, then it is detached from the memory to save memory.

From the running Modes of uncustomized page and customized page, we can see that their running efficiency is quite different. First, the uncustomized page is located on the disk and can be read quickly. Second, the uncustomized page will be compiled into a DLL when it is accessed for the first time, avoiding repeated compilation. For example, if the homepage "default. aspx" of two different SharePoint sites is uncustomized page and the same page template is used, the pages are compiled only once. While the customized page is located in the content database, the reading speed is inferior to that of the disk file, and it will not be compiled into DLL, but will only be parsed and run in the memory.

However, it is interesting that the mized page parsing operation method can be slow, but it needs to save some memory. It is because the structure of a page is loaded in the memory and can be released after parsing and running. After a DLL is loaded, it cannot be released. This is because. Net does not support loading the Assembly before uninstalling the assembly. (However,. Net supports creating appdomain and releasing it again .)

In addition to the storage location and running efficiency, uncustomized page and customized page differ greatly in code security. Similar to applicaton page, uncustomized page is also a page trusted by Sharepoint. ASP. NET in-line code in uncustomized page is directly run. The customized page can be added to any in-line code by the site designer (maybe not the server administrator) through SharePoint designer. Therefore, the default security rule does not allow the server code in the customized page to be run.

Similarly, if a server control is placed on the uncustomized page, there is no problem. However, if you want to place a server control (including Web part) on the customized page ), this control must be placed on the web site. config is marked as "safe control" (that is, a new "<safecontrol>" node is added to identify whether a control is secure ).

Although SharePoint imposes these security restrictions on the customized page, the server administrator can modify the default security restrictions by modifying the security settings in the web. config file. For example, if you want the pages under the "mypages" directory of the site to be included in the server in-line code even if they are customized pages. add the following content to config:
<SharePoint>
<Safemode...>
<Pageparserpaths>
<Pageparserpath virtualpath = "/mypages/*" compilationmode = "always"
Allowserversidescript = "true" allowunsafecontrol = "true" includesubfolders = "true"/>
</Pageparserpaths>
The value of the "compilationmode" node can be never, always, and auto. Set it to always to force compilation. "Allowserversidescript" specifies whether to allow server-side code. "allowunsafecontrol" specifies whether to allow unsecure controls (that is, the controls are not specified as secure in the "safecontrols" area.

Note that, although you can modify the settings in Web. config to allow all site pages to contain server code, do not do this unless necessary. This will enable the person with the permission to design the site. By using SharePoint designer, you can add in-line code on any page to perform any operations.

4. field controls and control templates
In addition to Web Components, pages in Moss 2007 can also contain "field controls ". The field control can be a simple ASP. NET 2.0-based control you have created. The ASPX page displays two modes: Read-only mode and edit mode.
WSS 3.0 and moss 2007 provide many default field controls that you can use directly on the page. All field controls on the moss 2007 website are rewritten to a base class named formcomponent in WSS 3.0. You can expand the default field controls in any WSS 3.0 and moss 2007 as needed. For example, you can write a custom field control that inherits the class baserichfield or other default field controls.
the control template is an important feature of ASP. NET 2.0. It separates the data layer from the presentation layer. The template defines the appearance of the control. All the field controls contained in the website use the template to define the layout. Developers can perform the following development:
★Create a deployment control template
★Deploy a custom template inherited from the default control template
★Edit a deployed template

the definition of a control template is similar to that of a field type. They have the same scalability and deployment model. All custom templates will be added to the newtemplate. ascx file. You can customize the control template in the following three ways.
★Use the getcontroltemplate method in the object model to set the control template
★Set the "templatename" or "alternativetemplatename" attribute in the webpage field control instance.
★In addition to customizing a template file and referencing it in the control, you can also customize the template-related XML tag of the control. This technology is most commonly used by web designers who do not have the permission to install new templates and want to change the appearance and visual effects of controls.
when moss 2007 is configured, a website uses the template tag, templatename attribute, and getcontroltemplate method in the following sequence during running. However, the template designer can modify this method by reloading the getcontroltemplate method. All controls inherit from the formcomponent base class. The getcontroltemplate method of this base class can be overloaded to define the template used by the control. The built-in logic of the template is applied to every instance based on this control.

5.Page Processing Model

Moss 2007 uses a template-based rendering system. The two most basic templates for link page rendering are the master page and page layout. The master page is applied to all pages of the website, and the page layout is applied to all pages created based on the layout. The page layout is stored as a list item in the "Master page and page layout" document library of top-level websites, therefore, you can use version control, check-in and checkout, workflows, and any other features based on the SharePoint document library for scaling.

Moss 2007 is built on wss3.0 and ASP. NET 2.0. The ASP. net engine is responsible for compiling and running all SharePoint page requests. For example, if a user requests to access a page called welcome. aspx from a browser. The ASP. net engine uses the fileprovider object of wss3.0 to call the page layout and website-related master pages related to this page, and then continues rendering the field controls and Web components on the page. The following figure shows the page processing model of moss 2007.

 

Page Processing Model

The following list illustrates how ASP. net2.0 and wss3.0 interact during page rendering for a SharePoint Website:

1.The browser sends a page browsing request to the IIS server.

2.IIS sends this request to ASP. NET 2.0

3.An httpaplication pipeline for this request is created.

4.ASP. NET 2.0 extracts page files from wss3.0's "file Extraction Tool. ASP. NET passes the URL to the "file extraction server", and the "file extraction server" retrieves the file and returns the "Data Stream" of the page ". The WSS file Extraction Tool is responsible for caching and database access optimization.

5.ASP. NET loads the page class, analyzes the page data, and finds reference to the page layout.

6.The ASP. net engine compiles the page data stream and stores it in the memory.

7.ASP. NET uses the WSS file Extraction Tool to call the page layout.

8.ASP. NET loads the data stream of the page layout related to this page.

9.ASP. NET compiles the page layout and stores it in memory. If the system requires memory, ASP. NET can release this part of Memory later.

10.ASP. NET confirms the master page used for this page, and obtains this file through the WSS file Extraction Tool.

11.ASP. NET compiles this master page and writes it back to the disk. Therefore, this compilation is only performed once unless you have modified this master page.

12.The page layout runs each control defined on the page content.

13.ASP. NET updates all required caches.

14.IIS returns all data on this page to the browser.

If the next page is accessed by the same user with different names but with the same permissions, the page processing process will be more efficient:

1.The browser sends a page access request to IIS.

2.IIS sends this request to ASP. NET 2.0

3.To process the request, an httpapplication pipeline is created, and the handlerequest method is used.

4.ASP. NET uses all internal caches.

5.HTML code of the ASP. NET Rendering Control.

6.IIS returns the page to the browser.

Tip: each step consumes a very small amount of CPU time. In addition, unless you enable the page output cache function of ASP. NET 2.0, ASP. NET renders the control every time by default.

References:
1. Microsoft Office Sharepoint Server SDK
2. kaneboy's blog
3. http://bbs.msotec.net/

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.