Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8249999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:44:06+00:00 2026-06-07T23:44:06+00:00

I am porting a classic ASP.NET application (ASPX pages) to ASP.NET MVC 3. Currently

  • 0

I am porting a classic ASP.NET application (ASPX pages) to ASP.NET MVC 3. Currently I use ContentPlaceHolder(s) to dynamically add content to specific ASP.NET ASPX pages. Consider the following:

<!DOCTYPE html>
<html>
    <head>
        <link href="MyStyleSheet.css" rel="Stylesheet" type="text/css" />
        <asp:ContentPlaceHolder ID="Styles">
        </asp:ContentPlaceHolder>
        <script type="text/javascript" src="jQueryAndOtherScripts.js"></script>
        <asp:ContentPlaceHolder ID="Scripts">
        </asp:ContentPlaceHolder>
    </head>
    <body>
        <div id="Container">
            <asp:ContentPlaceHolder ID="Content">
            </asp:ContentPlaceHolder>
        </div>
    </body>
</html>

So in the snippet above I have 3 content place holders so I can add addition styles, scripts and content based on the individual page. The reason I have done it this way is so that each page only loads the styles, scripts relevant to the content on the page (for example if it was the login page, I might add a script to check that the login details are valid)

Consider the following MVC 3 Razor View snippet:

<!DOCTYPE html>
<html>
    <head>
        <link href="MyStyleSheet.css" rel="Stylesheet" type="text/css" />
        <script type="text/javascript" src="jQueryAndOtherScripts.js"></script>
    </head>
    <body>
        <div id="Container">
            @RenderBody()
        </div>
    </body>
</html>

Now for the problem…RenderBody() replaces <asp:ContentPlaceHolder ID="Content"></asp:ContentPlaceHolder>, but what do I use as a replacement for <asp:ContentPlaceHolder ID="Styles"></asp:ContentPlaceHolder> and <asp:ContentPlaceHolder ID="Scripts"></asp:ContentPlaceHolder> ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T23:44:10+00:00Added an answer on June 7, 2026 at 11:44 pm

    Sections are the way to achieve this. Check out this excellent post by ScottGu on the subject.

    http://weblogs.asp.net/scottgu/archive/2010/12/30/asp-net-mvc-3-layouts-and-sections-with-razor.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am researching the possibility of porting an application written in classic ASP with
I’m looking for a book that explains how to use ASP.Net MVC, Razor and
So I am porting a legacy application over from coldfusion to asp.net/c#. My problem
I'm porting a website from PHP to ASP.NET MVC, and I'm trying to mimic
Porting an application from C# (1.1 framework) to VB.NET (3.5 framework), and I have
I am currently porting an application from iOS into Android and I have ran
I'm porting a native library to a NDK application. When I try to use
I'm working on porting a large vb6 application to .NET. The current app is
Clarification: this is not about user agent calls to pages, but Classic ASP calling
Porting over an application to use NHibernate from a different ORM. I've started to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.