All Questions

27
votes
2answers
3531 views

Post an HTML Table to ADO.NET DataTable

I have a HTML table as below in my View: <table id="tblCurrentYear"> <tr> <td>Leave Type</td> <td>Leave Taken</td> <td>Leave Bala...
5
votes
2answers
4458 views

Pass List of Checkboxes into View and Pull out IENumerable

I have a list of items that will be associated to a user. It's a one-to-many relationship. I want the entire list of items passed into the view so that they can choose from ones that are not associate...
5
votes
1answers
4792 views

MVC5 Razor html.dropdownlistfor set selected when value is in array

I'm developing an ASP.NET MVC 5 application, with C# and .NET Framework 4.6.1. I have this View: @model MyProject.Web.API.Models.AggregationLevelConfViewModel [...] @Html.DropDownListFor(m => m...
359
votes
12answers
284878 views

Using Razor within JavaScript

Is it possible or is there a workaround to use Razor syntax within JavaScript that is in a view (cshtml)? I am trying to add markers to a Google map... For example, I tried this, but I'm getting a to...
259
votes
44answers
238239 views

Entity Framework: "Store update, insert, or delete statement affected an unexpected number of rows (0)."

I am using Entity Framework to populate a grid control. Sometimes when I make updates I get the following error: Store update, insert, or delete statement affected an unexpected number of rows (0)...
149
votes
10answers
49856 views

Dynamic Anonymous type in Razor causes RuntimeBinderException

I'm getting the following error: 'object' does not contain a definition for 'RatingName' When you look at the anonymous dynamic type, it clearly does have RatingName. I realize I can do this ...
255
votes
20answers
156466 views

Injecting content into specific sections from a partial view ASP.NET MVC 3 with Razor View Engine

I have this section defined in my _Layout.cshtml @RenderSection("Scripts", false) I can easily use it from a view: @section Scripts { @*Stuff comes here*@ } What I'm struggling with is how...
645
votes
9answers
226233 views

How do I import a namespace in Razor View Page?

How to import a namespace in Razor View Page?
120
votes
5answers
133048 views

Mix Razor and Javascript code

I'm pretty confused with how to mix razor and js. This is the current function I am stuck with: <script type="text/javascript"> var data = []; @foreach (var r in Model.rows) ...
440
votes
12answers
160521 views

Escape @ character in razor view engine

I am creating a sample ASP.NET MVC 3 site using Razor as view engine. The razor syntax starts with @ character e.g. @RenderBody(). If I write @test on my cshtml page it gives me parse error CS0103...

Previous Next