Highlighting kills my Razor syntax in Visual Studio 2010 - visual-studio-2010

I'm using Expression theme in Visual Studio 2010 Ultimate on Windows 7 operating system. (Note: Actually, I'm not sure this problem occurs because of the dark theme) A few days ago, I decided to learn ASP.NET MVC 4 and tried to create a small web application. In Visual Studio, I followed this instruction and created a new asp.net mvc 4 web application: File->New->Project->ASP.NET MVC 4 Web Application.
Everything was perfect. But when I opened the Login.cshtml file, I couldn't even see the razor syntax (expressions which started #) because of highlighting. Take a look:
Even if I select all the text with CTRL + A in Visual Studio, I barely see the syntax.
Because of that, I can't even start to learn asp.net mvc. I started to look for a solution for this situation on the internet, but I couldn't find any useful answer. In Visual Studio, I looked the Tools->Option->Font and Colors option, but I couldn't find anything for this either. This problem shows only when I'm working in a View (for the Razor). There is no highlighting problem in Model, Controller or any other code files.
User ray247 asked a question close enough to my question called Where can I change the Asp.net MVC 3 Razor syntax hightlighting in VS10? but I still can't find a solution. I don't want to stop using my dark theme. It's really good for my eyes.

You should be able to change the text background for Razor code by:
Opening Visual Studio Options (Under Tools -> Options),
Selecting "Fonts and Colors" (Under Environment in the treeview at left)
Changing the dropdown box at top to "Text Editor" (if that isn't the value already),
Choosing "Razor Code" from the "Display Items" listbox, and
Changing the background color to your liking and clicking "OK" to apply the change.
There's also an "HTML Server-Side Script" setting that controls the background color of the Razor code delimiters (the # expression and similar expressions that mark the beginnings of code blocks.)
HTH,
Clay

Related

Syntax coloring on unity visual studio?

For some reason nearly everything is simply white, I'd prefer the more varying colors based on like, what kind of thing you are typing. I just recently started so I don't know the terminology. I see a lot of Unity tutorials that have coloring like that. Thanks!
I'm using a cs file
I think what may work for u is this
Inside Visual Studio - go to Tools and scroll to Options
Text Editor
C# and then Advanced
and choose Visual Study 2019 under Editor Color Scheme
You may need to reload the project. In Solution Explorer it may state:
Assembly-CSharp (unloaded)
Right click this text and select Reload Project from the resulting context menu

Visual Studio 2010 To Blend 4 Not Working Right

Visual Studio and Blend 4 Design Problem
I have a VS 2010 C# solution file that I am opening in Blend 4. The file opens with no errors, however if I attempt to build it in Blend the program lists a few missing references and then crashes Blend. Here is the issue that I am really trying to solve since I think I can solve the missing references in due course. Once the solution is opened in blend the Design tool for any XAML does not display at all. VIEW >> Active Document View >> Design View, etc. are all grayed out. What is the secret to having a programmer work in VS and hand off solution files for a designer like me to work on GUI in Blend. It seems MS has made this a difficult procedure to master.
It sounds like you created the project using the Class Library project template instead of the WPF User Control Library template. When you put these two project files side by side, you'll see that the WPF User Control Library project has this additional line near the top of the project file:
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
This is what tells Blend it can display a design surface for the items in the project. There's lots of stuff you can make in Visual Studio that cannot be displayed in Blend, so Visual Studio needs some way of communicating to Blend that it should attempt to load designers. Edit your .csproj file to contain the above GUIDs and I bet it will work.

Shortcut keys not working (Visual Studio 2010 with ASP.NET MVC 3 RC1)

None of these shortcut keys appear to be working for me in VS 2010 with ASP.NET MVC 3 RC1.
I particularly would like to use CTRL + M, CTRL + G to "Go To Controller" but I keep receiving the error:
The key combination (CTRL+M, CTRL+G)
is bound to command (Go To Controller)
which is not currently available.
Thrown by the VS IDE. I have tried this obviously within an ASPX view file in Source code mode, but no luck. I receive the same error for all shortcuts tried.
PS: I am running ReSharper 5; could this be interfering?
The shortcut keys in ASP.NET MVC 3 unfortunately conflict with the shortcuts from ASP.NET MVC 2. This means that when both products are installed (or, at least, their VS add-ins) the shortcuts won't work properly.
One workaround is to uninstall the versions of ASP.NET MVC that you are not using. You can uninstall the "tooling" components from Add/Remove Programs in the Windows Control Panel.
The specific example you give (Go To Controller) is listed on the RC Known Issues list:
When you are editing a Razor view (.cshtml file), the Go To Controller menu item in Visual Studio will not be available, and there are no code snippets.
They don't mention the other keyboard shortcuts, but I assume they will be added back in when this issue is addressed.
Note: there is another item listed about Intellisense and Resharper, so you may want to take a look at the rest of the list.
I had a similar issue just now, when my keys simply stopped working. I would press Ctrl+R R, for instance ("rename"), and would get the "..not currently available" message. Doing the same from the ReSharper menu however, would work fine.
I still have no idea what caused the conflict, but this solved it in any case:
Select Toos --> Options, and ReSharper on the left.
Click the Options button to open the ReSharper settings.
Now, under "Visual Studio Integration", make sure "Visual Studio" is selected under Keyboard Shortcuts (or whichever sheme you want)
Click Save (Note: you might have to click OK in the VS Options window first, even though it is hidden behind the R# winodow)
Now try using a ReSharper command again, and it should either work directly, or prompt you for a desired scheme to apply, as it did the first time you started using R#.

WPF Applications: Visual Studio vs. Expression Blend

I am a bit confused on how Visual Studio 2010 and Expression Blend 4 operate together. If I want to create a WPF application, should I start it in Expression Blend 4? If so, then how does Visual Studio 2010 natively open Expression Blend projects, or does it?
Or should I start my application in Visual Studio 2010? If so, how do I open my solution in Expression Blend.
Also, how do I modify an existing WPF form, if I need changes. If I already have events handled and code behind, how do I bring it over to expression blend, make my changes, then bring it back to visual studio without disrupting the events and code that I have created in Visual Studio 2010?
Also can someone recommend a good book that covers how to create WPF and/or Silverlight applications using Expression blend 4 and Visual Studio 2010 together.
Solutions are the same for Visual Studio and Expression Blend. You can open your solution through the file menu in expression blend, or by right clicking on a xaml file in Visual Studio and select "Open In Expression Blend".
Personally, when I need to make only a small change, like changing the text on a button, I don't go into Blend. But when I want to see what's going on, with margins and layout and stuff I always use Blend. Most often I have Visual Studio and Blend open side by side and I keep switching back and forth.
Because Expression Blend uses the same solution you don't have to worry about event handlers and such. When they are in place, they stay in place. Unless you delete the control the event is attached to of course.
Creating a solution can be done in both tools, but I start most projects in Visual Studio. There are however a few Project templates that can't be found in visual studio. For example the Databound Application project type. This will give you a start on an MVVM project, with folders in place for the Model, View and ViewModel.
You can have it open in both Visual Studio and Blend at the same time. You're prompted in Visual Studio if you make a change in Blend and vice versa.
Personally I create the new application in Visual Studio first then open it in Blend.
I usualy start my project in Blend.
Remember Blend is specially designed to make great UI, easy databindig, make easy templates and custom controls.
You can edit the code behind of your app directly in Blend but sometimes it doesn't show the intellisense; thats when you need open VS, to do that right click on your project inside blend and click on edit with Visual Studio. It'll launch VS and you can start coding.
You dont need to close VS or Blend, they booth can be open, if you make some change in VS it will notify Blend, will appear a dialogbox telling you: reload the app, click Yes the changes will be sincronized in Blend and VS, the same happens when you make changes in Blend and go to an already open instance of VS.
Too remember to install de VS tools, it will allow you to open Silverlight projects inside VS, if they arent already installed an error message will appear.
Hope my answer help you

Shortcuts for web controls and HTML snippets in Visual Studio

Consider the feature in Visual Studio 2010 for snippets in the HTML Source view of a web page.
type a control name in plaintext with no markup or brackets!
... e.g. hyperlink.
Then hit Tab
Your web control has been auto-completed for you. It's up to you to fill in the other details that you need.
This works for form as well:
<form action="default.aspx" method="post">
</form>
This looks like a real time saver. This is supported in WebForms and ASP.NET MVC projects.
What other snippets are available in Visual Studio 2010 in the Source view of a page?
For the authoritative list of snippets, check out the VS2010 installation folders where the snippets are stored:
C:\Program Files\Microsoft Visual Studio 10.0\Web\Snippets\HTML\1033
There is one folder for ASP.NET and one for plain HTML snippets.
Also, if you use jQuery a lot, there is a set of jQuery snippets that you can add to Visual Studio as well.
Here are a ton (100's) of the short cuts in Visual Studio right from MSDN:
http://msdn.microsoft.com/en-us/library/da5kh0wa.aspx
The one thing that has been around forever but a lot of people forget about is block selection done by holding down the ALT key and use the mouse to select a block of text. Great when you want to copy/cut/delete a bunch of code that is lined up but you don't want the whole line.
Yeah, this is a really cool new set of snippets in VS2010. Here are the articles I used to learn it:
Walkthrough: Using HTML
Snippets
Using HTML Code Snippets in Visual
Studio 2010

Resources