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

  • Home
  • SEARCH
  • 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 6473463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:28:10+00:00 2026-05-25T06:28:10+00:00

asp:PlaceHolders have a visible property, and this controls whether their content is rendered on

  • 0

asp:PlaceHolders have a visible property, and this controls whether their content is rendered on the page.

I have declared a PlaceHolder in an MVC2 Master Page and set it’s visibility to false.

Please can you tell me how I can control the visibility of a PlaceHolder from within an MVC2 view template that inherits from an MVC2 master page?

This seems like a simple task, but I am struggling to see how it can be achieved. I think I should be able to get access to the PlaceHolder from within the descending view template (as with web forms code-behind) and just set it’s visibility there but the way to do this is escaping me…

  • 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-05-25T06:28:11+00:00Added an answer on May 25, 2026 at 6:28 am

    Don’t do this. Placeholders are legacy from classic WebForms. Manipulating server side controls in an ASP.NET MVC application is very bad and you should never do it. So simply forget about setting properties on user controls. Fortunately in Razor placeholders have been completely removed and replaced by sections. So don’t write code that you won’t be able to migrate later.

    One way to show/hide sections of your code in an ASP.NET MVC application is to use an if statement in your views. For example:

    <% if (Model.ShouldShowSection) { %>
        <div>Some super section</div>
    <% } %>
    

    In this example we are testing a boolean value on the view model which the controller action that rendered this view would set.

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

Sidebar

Related Questions

ASP.NET server-side controls postback to their own page. This makes cases where you want
For example, if i have on the aspx page: <asp:PlaceHolder ID=tab_0 runat=server Visible=false></asp:PlaceHolder> <asp:PlaceHolder
I have an aspx contentpage wherein there are two placeholders. <asp:PlaceHolder ID=plh1 runat=server Visible=false>
I have added placeholder to a page as below. <tr > <td > <asp:PlaceHolder
I have the following user-control: <%@ Control Language=C# AutoEventWireup=true CodeFile=FadingMessage.ascx.cs Inherits=includes_FadingMessage %> <asp:PlaceHolder Visible=false
If I have an asp.net web page with placeholders, what is the simplest way
I have a ASP.NET page with 2 user controls registered. The first one has
I have this code in my .aspx file <asp:UpdatePanel runat=server ID=UpdatePanel1 UpdateMode=Conditional> <ContentTemplate> <asp:PlaceHolder
I have a asp DataList that gets populated by a DataTable . <asp:PlaceHolder ID=ph3
In an ASP.NET project I have the following HTML: <asp:PlaceHolder ID=plcTitle runat=server></asp:PlaceHolder> <div id=divStrapline

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.