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 8774831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:40:00+00:00 2026-06-13T18:40:00+00:00

Is it possible to do something like this in Razor: @using(Html.CMSContent(TermsOfService)) { <text> <!–

  • 0

Is it possible to do something like this in Razor:

@using(Html.CMSContent("TermsOfService")) 
{
    <text>
        <!-- Some default content goes here if the "TermsOfService"
             item doesn't exist in my content table in the database -->
    </text>
}

When the view is being processed, if the CMSContent helper doesn’t find a content item named “TermsOfService” in some database table I’ve set up, it’ll output the default content.

Otherwise, it’ll replace the default content with what’s in the database?

I’m trying to build a CMS/application hybrid, so that the Marketing department can override the text in my app if they want.

CLARIFY

The reason I’m doing this is to make the code super-easy to read and write. I’m going to end up with these little content blocks all over the place, so I’m hoping to minimize how much a developer has to type to get this functionality.

I’m also expecting that 99% of the time, the default text is what’s going to show up. But I’d like to have the 1% cases handled where we need to quickly change some text without having to re-deploy the app. So, having the default text as close to its context as possible is important (ie, I don’t want the developer to have to jump to a different file to see what the default text is – nor have to jump to the top of the page).

For example, when you do @using(Html.BeginForm()) it’ll automatically emit the start and end <form> tags. I’m hoping for something clever like that.

  • 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-13T18:40:02+00:00Added an answer on June 13, 2026 at 6:40 pm

    I think I figured out what I was looking for. It uses an if instead of using:

    if(!Html.CMSContent("TermsOfService"))
    {
         <text>
               Default content goes here
         </text>
    }
    

    For the helper:

    public static bool CMSContent(this HtmlHelper Html, string BlockName)
    {
         if (blockname in database)
         {
             var blockdata = (retrieve from database);
             Html.ViewContext.HttpContext.Response.Write(blockdata);
             return true;
         }
         else
         {
             return false;
         }
    
    }
    

    Although I’m not sure that using Response.Write is the best way to do it.

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

Sidebar

Related Questions

Is it possible to accomplish something like this using linqtosql? select * from table
Is it possible to to something like this using Spring.NET IoC container? MyClass instance
Is it possible to do something like this : <property name=template value=file:/some/resource/path/myTemplate.txt /> via
is it possible to do something like this in objective-c (using categories or something
Is it possible to do something like this? var pattern = /some regex segment/
Is possible create something like this without using ActionBar? I just need button which
there is possible make something like this in php ? <script type=text/javascript> for(i=0; i<5;
Is it possible to do something like this: Dim ThisThing as ThisThingToolStripMenuItem.Text So i
Is it possible to do something like this in Java? Object[] objArray = {
Is it possible to do something like this? public function something() { $thisMethodName =

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.