Several Methods for Sharepoint to dynamically display list data on the master page

Source: Internet
Author: User

As we all know, in Sharepoint, content page inherits from page layout, while page layout inherits from master page. As we all know, the role of master page defines the overall appearance and public elements of the site, so it has a strong page reusability and a good page editing experience, page layout uses contentplaceholder to deploy some pages with strong content similarity. So when we get to the content page, all we do is to put the content we want to display on each page, you don't have to worry about the remaining la S and styles.

 

Okay. Let's start with this! Now let's talk about the point. Let's start with the requirement. The customer requires that the footer part of the entire site dynamically read data from the site list to generate it, instead of writing it to the master page, for example, the following figure indicates that the customer wants to dynamically update the footer part of the site by maintaining a list of data in the future, and append the sorting and display functions, they all have a field in the list to control, instead of being updated by IT personnel.

 

 

For this requirement, we can implement the following methods:

 

(1) The first thought was to write a customized user control and call the object model to present data. After the DLL is deployed, you must register the reference on the master page before using it. This method is good, but not easy to maintain. If there are any logical changes, you need to redeploy the DLL to the server, which is often not very convenient.

 

(2) The second method is to use the Content Query Web part. Can someone say that the master page can contain Web parts? Dynamic Web parts cannot be added to the master page, because the content of the master page cannot be modified from the page, but we can put static Web parts, static means that the Web part is not in the Web Part zone. The procedure is as follows:

1. Create a temporary test page, add a Content Query Web part, and configure Web parts, such as data sources, filtering conditions, sorting, and other attributes.

2. use SPD to separate the page from layout, open it, and find the corresponding Web Part zone. We found that the zone contains a <publishingwebcontrols: contentbyquerywebpart>, which is actually a control, copy the control and place it in the HTML element of the master page. Do not use the Web Part zone.

3. Update the list data and refresh the page. You can see that footer is dynamically changing. Note: This error may occur when the environment is changed: there is a problem with the query that this Web part is issuing. check the configuration of this Web part and try again. this is because the listguid has changed, so we can use the listurl and listname attributes to control it when necessary, instead of using the listguid.

 

(3) The third method is to use the Web part, but instead of the data view Web part. Therefore, it should be similar to the second method and I will not elaborate on it.

 

the two methods have their own advantages and disadvantages. In comparison, the second or third method is easier to maintain because they are OOB's, the server-side Code is not involved. If the user does not allow the user to write the server-side code, the latter is not suitable. There may be other better ways to explore.

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.