How to change Visual Studio 2012 Razor colors

Optional: Install the color theme editor: http://visualstudiogallery.msdn.microsoft.com/366ad100-0003-4c9a-81a8-337d4e7ace05 In the theme editor or Tools > Options > Environment > Fonts and Colors Search for: ‘HTML Server-Side Script’ to edit the foreground & background of @ and other tags. Search for: ‘Razor Code’ to edit the background of the Razor code.

Make sure all *.cshtml files are set to be “Content” for Build Action

You could extend the .csproj with a small snippet that will generate a warning when an item in the “None” group has the extension .cshtml. The snippet would be: <Target Name=”EnsureContentOnViews” BeforeTargets=”BeforeBuild”> <ItemGroup> <Filtered Include=”@(None)” Condition=”‘%(Extension)’ == ‘.cshtml'” /> </ItemGroup> <Warning Condition=”‘@(Filtered)’!=”” Code=”CSHTML” File=”$(MSBuildProjectDirectory)\%(Filtered.Identity)” Text=”View is not set to [BuildAction:Content]” /> </Target> If you see … Read more

ASP.NET MVC 4 – for loop posts model collection properties but foreach does not

the problem is not with the IEnumerable or the IList it the way you are rendering the collection in your view. @for(var i = 0;i < Model.People.Count;i++) { <tr> <td>@Html.TextBoxFor(m => Model.People[i].Name)</td> <td>@Html.TextBoxFor(m => Model.People[i].Age)</td> </tr> } Observe that with each list item you are appending a continuous index which enables the model binder to … Read more

Formatting Razor Files in Visual Studio Code

You can introduce them as HTML files (File -> Preferences -> Settings) without any 3rd party extensions: { “editor.formatOnSave”: true, “emmet.includeLanguages”: { “aspnetcorerazor”: “html” }, “files.associations”: { “*.cshtml”: “html” } } Update: v1.17.0 of C# for Visual Studio Code add-on added preview Razor (cshtml) language service with support for C# completions and diagnostics.

VS 2015 Razor Autocomplete/Intellisense dropdown hides immediately after dropdown

I haven’t found the root cause, but in all cases, CTRL+SPACE works. This isn’t the best, but light years better than nothing at all. (this shortcut is not one I’ve used in the past, so this is likely standard behavior, but…) If you’re at the dot Model. and autocomplete list disappears, CTRL+SPACE consistently brings it … Read more

How to use Bootstrap modal in Blazor client app?

There is likely a better way to do this, but here’s a working example to get you started: Page: @page “/modal-test” <BlazorApp1.Components.Modal @ref=”Modal”></BlazorApp1.Components.Modal> <button @onclick=”() => Modal.Open()”>Open Modal</button> @code { private BlazorApp1.Components.Modal Modal { get; set; } } Component: <div class=”modal @ModalClass” tabindex=”-1″ role=”dialog” style=”display:@ModalDisplay”> <div class=”modal-dialog” role=”document”> <div class=”modal-content”> <div class=”modal-header”> <h5 class=”modal-title”>Modal title</h5> … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)