Add ASP.NET Masterpage Afterwards

When you’ve got some existing ASP.NET pages and you later on want to add a common masterpage, do this:

Master Page

  1. Create a masterpage, e.g. Management.Master.
  2. Add the sub pages’ comon controls to the master.
  3. In the Management.Master, add ContentPlaceHolder items for head and body:


Sub Page

Do the following in the subpage.aspx:

  1. Add masterpagefile to page level directive:
    <%@ Page ... MasterPageFile="Management.Master"
  2. Remove the , ,
    and

    , tags.

  3. Replace the tag by the tag respecting the link to the ContentPlaceHolder via ID and ContentPlaceHolderID, like this:

    // former head content goes here

  1. Likewise replace the body tag by the tag:

    // former body content goes here

Sub Page Easy

If you've got nothing than the </code> tag inside of the <code><head></code> section, it is a bit easier:</p> <ol> <li>Add masterpagefile and title to page level directive:<br /> <code><%@ Page ... MasterPageFile="Management.Master" Title="Subpage"</code> </li> <li>Remove the <code><head></code> section.</li> <li>Replace the <code><body></code> tag by the <code><asp:Content...></code> tag respecting the link to the ContentPlaceHolder via ID and ContentPlaceHolderID, like this:</li> </ol> <pre><code><asp:Content ID="Cont1" ContentPlaceHolderID="CphBody" runat="server"> // former body content goes here </asp:Content> </code></pre> <p><em>Finish</em></p> </div><!-- .entry-content --> <footer class="entry-meta"> <span class="cat-links"> <span class="entry-utility-prep entry-utility-prep-cat-links">Posted in</span> <a href="https://99-developer-tools.com/category/tools/" rel="category tag">Tools</a> </span> <span class="sep"> | </span> <span class="tag-links"> <span class="entry-utility-prep entry-utility-prep-tag-links">Tagged</span> <a href="https://99-developer-tools.com/tag/asp-net/" rel="tag">ASP.NET</a> </span> </footer><!-- .entry-meta --> </article><!-- #post-1985 --> </div><!-- #content --> </section><!-- #primary --> <div id="secondary" class="widget-area" role="complementary"> <aside id="text-3" class="widget widget_text"> <div class="textwidget"><p><a href="/wp-content/uploads/2014/08/AJW-Palanga-108x144.jpg"><img loading="lazy" decoding="async" class="size-full wp-image-491 aligncenter" src="/wp-content/uploads/2014/08/AJW-Palanga-108x144.jpg" alt="Andreas Wicker" width="149" height="201" /></a></p> </div> </aside><aside id="text-4" class="widget widget_text"><h3 class="widget-title">Most Popular</h3> <div class="textwidget"><ul style="width: 220px; margin-left: 0px;"> <li><a href="/personal-kanban-kanbanpad/">Personal Kanban And Kanbanpad: Two Top Productivity Tools</a></li> <li><a href="/password-managers-not-safe/">Why Password Managers Aren’t Safe – And Won’t Ever Be</a></li> <li><a href="/notepad-function-list-tcl-bash/">Notepad++: Function List for Tcl and Bash</a></li> <li><a href="/notepad-programmers-editor/">Notepad++: Some Less Known Features</a></li> <li><a href="/why-zip-is-better-than-7z/">Why Zip is Better Than 7z</a></li> </ul> </div> </aside><aside id="meta-2" class="widget widget_meta"><h3 class="widget-title">Meta</h3> <ul> <li><a href="https://99-developer-tools.com/wp-login.php">Log in</a></li> <li><a href="https://99-developer-tools.com/feed/">Entries feed</a></li> <li><a href="https://99-developer-tools.com/comments/feed/">Comments feed</a></li> <li><a href="https://wordpress.org/">WordPress.org</a></li> </ul> </aside> <aside id="recent-posts-2" class="widget widget_recent_entries"> <h3 class="widget-title">Recent Posts</h3> <ul> <li> <a href="https://99-developer-tools.com/corflags-getassemblyname/">CorFlags, GetAssemblyName</a> </li> <li> <a href="https://99-developer-tools.com/dependency-walker/">Dependency Walker, dumpbin and ldd</a> </li> <li> <a href="https://99-developer-tools.com/bee-stings/">Bee Stings <%$, <%@, <%=, <%#</a> </li> <li> <a href="https://99-developer-tools.com/chartdirector-markup-language-cdml/">ChartDirector Markup Language CDML</a> </li> <li> <a href="https://99-developer-tools.com/curve-fitting/">Curve Fitting</a> </li> </ul> </aside><aside id="tag_cloud-3" class="widget widget_tag_cloud"><h3 class="widget-title">Tags</h3><div class="tagcloud"><ul class='wp-tag-cloud' role='list'> <li><a href="https://99-developer-tools.com/tag/net-library-ftp/" class="tag-cloud-link tag-link-8 tag-link-position-1" style="font-size: 8pt;" aria-label=".NET Library FTP (1 item)">.NET Library FTP</a></li> <li><a href="https://99-developer-tools.com/tag/7-zip/" class="tag-cloud-link tag-link-9 tag-link-position-2" style="font-size: 10.048780487805pt;" aria-label="7-zip (2 items)">7-zip</a></li> <li><a href="https://99-developer-tools.com/tag/7z/" class="tag-cloud-link tag-link-10 tag-link-position-3" style="font-size: 10.048780487805pt;" aria-label="7z (2 items)">7z</a></li> <li><a href="https://99-developer-tools.com/tag/applet/" class="tag-cloud-link tag-link-11 tag-link-position-4" style="font-size: 10.048780487805pt;" aria-label="Applet (2 items)">Applet</a></li> <li><a href="https://99-developer-tools.com/tag/asp-net/" class="tag-cloud-link tag-link-12 tag-link-position-5" style="font-size: 8pt;" aria-label="ASP.NET (1 item)">ASP.NET</a></li> <li><a href="https://99-developer-tools.com/tag/awk/" class="tag-cloud-link tag-link-13 tag-link-position-6" style="font-size: 8pt;" aria-label="Awk (1 item)">Awk</a></li> <li><a href="https://99-developer-tools.com/tag/bash/" class="tag-cloud-link tag-link-14 tag-link-position-7" style="font-size: 13.463414634146pt;" aria-label="Bash (5 items)">Bash</a></li> <li><a href="https://99-developer-tools.com/tag/book/" class="tag-cloud-link tag-link-15 tag-link-position-8" style="font-size: 8pt;" aria-label="Book (1 item)">Book</a></li> <li><a href="https://99-developer-tools.com/tag/browser/" class="tag-cloud-link tag-link-16 tag-link-position-9" style="font-size: 12.552845528455pt;" aria-label="Browser (4 items)">Browser</a></li> <li><a href="https://99-developer-tools.com/tag/c/" class="tag-cloud-link tag-link-17 tag-link-position-10" style="font-size: 18.016260162602pt;" aria-label="C# (14 items)">C#</a></li> <li><a href="https://99-developer-tools.com/tag/coding/" class="tag-cloud-link tag-link-18 tag-link-position-11" style="font-size: 11.414634146341pt;" aria-label="Coding (3 items)">Coding</a></li> <li><a href="https://99-developer-tools.com/tag/color/" class="tag-cloud-link tag-link-19 tag-link-position-12" style="font-size: 8pt;" aria-label="Color (1 item)">Color</a></li> <li><a href="https://99-developer-tools.com/tag/crashdump/" class="tag-cloud-link tag-link-20 tag-link-position-13" style="font-size: 8pt;" aria-label="Crashdump (1 item)">Crashdump</a></li> <li><a href="https://99-developer-tools.com/tag/cygwin/" class="tag-cloud-link tag-link-22 tag-link-position-14" style="font-size: 11.414634146341pt;" aria-label="Cygwin (3 items)">Cygwin</a></li> <li><a href="https://99-developer-tools.com/tag/debugging/" class="tag-cloud-link tag-link-23 tag-link-position-15" style="font-size: 13.463414634146pt;" aria-label="Debugging (5 items)">Debugging</a></li> <li><a href="https://99-developer-tools.com/tag/everybody/" class="tag-cloud-link tag-link-26 tag-link-position-16" style="font-size: 19.837398373984pt;" aria-label="Everybody (21 items)">Everybody</a></li> <li><a href="https://99-developer-tools.com/tag/fiddler/" class="tag-cloud-link tag-link-27 tag-link-position-17" style="font-size: 8pt;" aria-label="Fiddler (1 item)">Fiddler</a></li> <li><a href="https://99-developer-tools.com/tag/file-management/" class="tag-cloud-link tag-link-28 tag-link-position-18" style="font-size: 14.260162601626pt;" aria-label="File Management (6 items)">File Management</a></li> <li><a href="https://99-developer-tools.com/tag/ftp/" class="tag-cloud-link tag-link-29 tag-link-position-19" style="font-size: 10.048780487805pt;" aria-label="FTP (2 items)">FTP</a></li> <li><a href="https://99-developer-tools.com/tag/html/" class="tag-cloud-link tag-link-32 tag-link-position-20" style="font-size: 10.048780487805pt;" aria-label="HTML (2 items)">HTML</a></li> <li><a href="https://99-developer-tools.com/tag/image/" class="tag-cloud-link tag-link-33 tag-link-position-21" style="font-size: 10.048780487805pt;" aria-label="Image (2 items)">Image</a></li> <li><a href="https://99-developer-tools.com/tag/java/" class="tag-cloud-link tag-link-34 tag-link-position-22" style="font-size: 17.219512195122pt;" aria-label="Java (12 items)">Java</a></li> <li><a href="https://99-developer-tools.com/tag/kanban/" class="tag-cloud-link tag-link-35 tag-link-position-23" style="font-size: 8pt;" aria-label="Kanban (1 item)">Kanban</a></li> <li><a href="https://99-developer-tools.com/tag/linux/" class="tag-cloud-link tag-link-38 tag-link-position-24" style="font-size: 14.260162601626pt;" aria-label="Linux (6 items)">Linux</a></li> <li><a href="https://99-developer-tools.com/tag/notepad/" class="tag-cloud-link tag-link-42 tag-link-position-25" style="font-size: 10.048780487805pt;" aria-label="Notepad++ (2 items)">Notepad++</a></li> <li><a href="https://99-developer-tools.com/tag/pdf/" class="tag-cloud-link tag-link-44 tag-link-position-26" style="font-size: 11.414634146341pt;" aria-label="Pdf (3 items)">Pdf</a></li> <li><a href="https://99-developer-tools.com/tag/philosophy/" class="tag-cloud-link tag-link-45 tag-link-position-27" style="font-size: 11.414634146341pt;" aria-label="Philosophy (3 items)">Philosophy</a></li> <li><a href="https://99-developer-tools.com/tag/png/" class="tag-cloud-link tag-link-46 tag-link-position-28" style="font-size: 8pt;" aria-label="Png (1 item)">Png</a></li> <li><a href="https://99-developer-tools.com/tag/process/" class="tag-cloud-link tag-link-47 tag-link-position-29" style="font-size: 11.414634146341pt;" aria-label="Process (3 items)">Process</a></li> <li><a href="https://99-developer-tools.com/tag/publishing/" class="tag-cloud-link tag-link-48 tag-link-position-30" style="font-size: 11.414634146341pt;" aria-label="Publishing (3 items)">Publishing</a></li> <li><a href="https://99-developer-tools.com/tag/regex/" class="tag-cloud-link tag-link-49 tag-link-position-31" style="font-size: 8pt;" aria-label="Regex (1 item)">Regex</a></li> <li><a href="https://99-developer-tools.com/tag/russinovich/" class="tag-cloud-link tag-link-50 tag-link-position-32" style="font-size: 10.048780487805pt;" aria-label="Russinovich (2 items)">Russinovich</a></li> <li><a href="https://99-developer-tools.com/tag/security/" class="tag-cloud-link tag-link-51 tag-link-position-33" style="font-size: 14.260162601626pt;" aria-label="Security (6 items)">Security</a></li> <li><a href="https://99-developer-tools.com/tag/speed-test/" class="tag-cloud-link tag-link-52 tag-link-position-34" style="font-size: 8pt;" aria-label="Speed Test (1 item)">Speed Test</a></li> <li><a href="https://99-developer-tools.com/tag/sqlite/" class="tag-cloud-link tag-link-54 tag-link-position-35" style="font-size: 8pt;" aria-label="SQLite (1 item)">SQLite</a></li> <li><a href="https://99-developer-tools.com/tag/sql-server/" class="tag-cloud-link tag-link-53 tag-link-position-36" style="font-size: 10.048780487805pt;" aria-label="SQL Server (2 items)">SQL Server</a></li> <li><a href="https://99-developer-tools.com/tag/svg/" class="tag-cloud-link tag-link-55 tag-link-position-37" style="font-size: 8pt;" aria-label="Svg (1 item)">Svg</a></li> <li><a href="https://99-developer-tools.com/tag/task-management/" class="tag-cloud-link tag-link-56 tag-link-position-38" style="font-size: 8pt;" aria-label="Task Management (1 item)">Task Management</a></li> <li><a href="https://99-developer-tools.com/tag/tcl/" class="tag-cloud-link tag-link-57 tag-link-position-39" style="font-size: 13.463414634146pt;" aria-label="Tcl (5 items)">Tcl</a></li> <li><a href="https://99-developer-tools.com/tag/time-management/" class="tag-cloud-link tag-link-58 tag-link-position-40" style="font-size: 8pt;" aria-label="Time Management (1 item)">Time Management</a></li> <li><a href="https://99-developer-tools.com/tag/tool/" class="tag-cloud-link tag-link-59 tag-link-position-41" style="font-size: 22pt;" aria-label="Tool (33 items)">Tool</a></li> <li><a href="https://99-developer-tools.com/tag/unicode/" class="tag-cloud-link tag-link-60 tag-link-position-42" style="font-size: 8pt;" aria-label="Unicode (1 item)">Unicode</a></li> <li><a href="https://99-developer-tools.com/tag/unit-tests/" class="tag-cloud-link tag-link-61 tag-link-position-43" style="font-size: 10.048780487805pt;" aria-label="Unit Tests (2 items)">Unit Tests</a></li> <li><a href="https://99-developer-tools.com/tag/visual-studio/" class="tag-cloud-link tag-link-62 tag-link-position-44" style="font-size: 10.048780487805pt;" aria-label="Visual Studio (2 items)">Visual Studio</a></li> <li><a href="https://99-developer-tools.com/tag/zip/" class="tag-cloud-link tag-link-64 tag-link-position-45" style="font-size: 8pt;" aria-label="Zip (1 item)">Zip</a></li> </ul> </div> </aside><aside id="recent-comments-2" class="widget widget_recent_comments"><h3 class="widget-title">Recent Comments</h3><ul id="recentcomments"><li class="recentcomments"><span class="comment-author-link">Ulla</span> on <a href="https://99-developer-tools.com/impressum/#comment-2">Impressum</a></li><li class="recentcomments"><span class="comment-author-link"><a href="http://99-developer-tools.com/how-to-move-thunderbird-to-another-computer/" class="url" rel="ugc">How to Move Thunderbird to Another Computer | 99 Developer Tools</a></span> on <a href="https://99-developer-tools.com/how-to-move-firefox-to-another-computer/#comment-61">How to Move Firefox to Another Computer</a></li><li class="recentcomments"><span class="comment-author-link"><a href="http://99-developer-tools.com/all-you-need-is-love/" class="url" rel="ugc">All You Need is Love | 99 Developer Tools</a></span> on <a href="https://99-developer-tools.com/visual-studio-2013-free/#comment-57">Visual Studio 2013 for Free</a></li><li class="recentcomments"><span class="comment-author-link"><a href="http://99-developer-tools.com/four-essential-firefox-add-ons/" class="url" rel="ugc">Four Most Essential Firefox Add-Ons And Settings. Plus Seven Extras. | 99 Developer Tools</a></span> on <a href="https://99-developer-tools.com/leechblock-is-from-heaven/#comment-60">LeechBlock is a Junkie’s Cure From Heaven</a></li><li class="recentcomments"><span class="comment-author-link">Andreas J. Wicker</span> on <a href="https://99-developer-tools.com/zoomit/#comment-59">Zoomit</a></li></ul></aside> </div><!-- #secondary .widget-area --> </div><!-- #main --> <footer id="colophon"> <div id="site-generator"> <a href="https://wordpress.org/" class="imprint" title="Semantic Personal Publishing Platform"> Proudly powered by WordPress </a> </div> </footer><!-- #colophon --> </div><!-- #page --> </body> </html>