Recently QQ Group has a friend asked, how to insert their own development of WebPart in the master page. In fact, the master page is not allowed to insert WebPartZone, but the designer can insert a WebPart, or it can be manually registered, and then inserted into a WebPart, but when the designer is inserted, it is automatically registered in the head.
First we develop a test WebPart, the code is simple, just enter a paragraph of text, and then deploy to the site, such as:
For example, I want to modify PageTitle, a WebPart that is customized for us, such as:
In the following position, insert our webpart (I am F12 on the page to find an ID called PageTitle, and then determine that the node is the location), such as:
Do not delete the following node (delete the ContentPlaceHolder node will be error!) ), but cut to the bottom and set the visible to false, such as:
Place the mouse cursor where you want to insert it, and click a WebPart on the menu, such as:
Choose the WebPart that we just developed for testing, such as:
After inserting a WebPart, for example, it has part registration information, the following location has a reference to the part, and if you do not have to insert a WebPart UI, you can register and insert a WebPart manually;
Of course, the location of the insertion, there may not be the position of the cursor, I am accustomed to cut over, easy to use; remember not to interrupt any existing tags, or will error;
Reopen the page and find that the title has not changed, but the tab above has changed, (⊙﹏⊙) b!
Originally I changed the wrong position, if you want to add webpart to the corresponding location, you must remember to find the right location Oh!!
Total Knot
Add a WebPart to a SharePoint master page that's basically the way it is, is it simple?! Some people will ask, if you need to edit what to do, my suggestion is to go to a sitepage page to add WebPart, edit, and then the code copied over, there is a need, you can try, remember not to copy WebPartZone, otherwise error!
SharePoint 2013 Inserts a WebPart in a master page