Extract ContentPlaceHolder and Create Master (ASP.NET)
2 min to read
Creates a new master page using the code outside of the selection.
If you've created a page that you feel would be great to use as a template for other pages, the Extract ContentPlaceHolder and Create Master (ASP.NET) will be of great help to you. You simply select the content that you want to be changed dynamically, and apply this refactoring. All the code outside the selected block (the template) will be moved to a newly created .master page that will have a content placeholder at the extraction point. The selected code block will remain within the same page and will refer to the content placeholder. As a result, the operation won't change the page's appearance, but will make it much easier to dynamically change the extracted content.
when an ASPX code portion is selected within a .aspx file.
Extract ContentPlaceHolder and Create Master (ASP.NET) surrounds the initially selected code block with <asp:content> tags. The content outside the selection is moved to a new file and <asp:contentplaceholder> tag is placed at the extraction point. The Extracted content refers to the placeholder by id.
The newly created file is named NewMasterPageFile.master. If a file with this name already exists, the file is named NewMasterPageFile1.aspx, etc.
Rename is automatically activated for the content placeholder id so you can provide a meaningful string. Note that a reference to this id from the extracted code block is also updated.
If you haven't changed the placeholder's id right away, you can invoke Rename for it later.