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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:54:22+00:00 2026-06-02T20:54:22+00:00

I am managing my style declarations in a .cshtml file so I can dynamically

  • 0

I am managing my style declarations in a .cshtml file so I can dynamically code values, for example color-codes that I need to be repeat often. I’m using MVC’s routing capabilities to serve up the stylesheet with a .css extension, so this is all opaque to the end-user.

The .cshtml file contains mostly CSS, of course, with only a few dozen values passed in dynamically, and some calls to helpers I’ve written to make the CSS easier to maintain, so I’d like to be able to view this file with CSS code-highlighting.

QUESTION:
Is is possible to set the language for syntax hightlighting manually for a given file with Visual Studio?

Note: I know this is easy with Notepad++, but I’d prefer to do everything with the same editor.

UPDATE: I’v realized this problem can (I think) be cooked down to “Where is the executable for the the CSS Source Editor (default) ?”. This is an option when choosing “Open With…” on a CSS file, but not an option when choosing “Open With…” on a .cshtml file, so if I could just navigate to its location using the “Add” button in that wizard, my problem is solved. But…where is that editor??!

UPDATE (2): My hack works, but as it is ugly, I’d still like to know how to open in the default CSS editor.

UPDATE (3): I could really use a solution here, and it seems a general solution would be beneficial in many circumstances. Hence the bounty.

UPDATE (4): OK, My hack really does work — you just have to open the file with the VS’s HTML Editor instead of the Razor editor.

  • 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-02T20:54:24+00:00Added an answer on June 2, 2026 at 8:54 pm

    Here’s my hack:

    You can open a .cshtml file with Visual Studio’s HTML editor, and that editor will recognize CSS if nested inside <style> tags. But since the <style> (or any) tag is invalid inside a .css file, and will cause styles to break, the way around this is to embed the open and closing tags in razor or CSS comments:

    /*<style>*/
    
    [my style declarations]
    
    /*</style>*/
    

    OR:

    @*<style>*@
    
    [my style declarations]
    
    @*</style>*@
    

    Yuck. But it works.

    update It does work — just be careful to select VS’s HTML editor and not the Razor editor when using “open with…”

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

Sidebar

Related Questions

I am managing a quite large python code base (>2000 lines) that I want
For managing some cache, I need a sort of Hashtable with the ability to
What tool for managing Oracle DB do you suggest? I need to execute scripts
I have a problem that might be a simple one, but can't find a
I need to create an asp.net page that auto generate a brackets tournament tennis
Managing url paths can be a real pain in ASP.NET. AbsolutePath vs RelativePath vs
I am managing to construct a form (with FuelCMS) that has a look-up table,
I'm currently managing a legacy rails application that's running on rails 1.2.7. One of
i'm managing a date that comes from an Alfresco Properties and is in the
In a site I am managing, I have this styled link that on click

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.