Anyone heard of NCV 5?

Sorry if this is a dumb question…

Anyway I have an interview for a job coming up – C# .NET developer (mainly web).

One of the requirements is knowledge of NCV5… But I have never heard of it. Google isn't really bringing back any results either.

I assumed maybe it is a typo – and should be MVC5 – but it's a pretty well designed poster – not just a scibbled together word doc, so I'd expect they would proof read these things.

Am I out of touch?

by red_dwarf_fan via /r/csharp

Property setter bad behavior?

If property coerce its value to another one inside setter implementation like this:

private int _foo; public int Foo { get { return _foo; } set { if(value < 0) value = 0; _foo = value; } } 

Do you think this kind of behavior should be considered bad practice?

by EBCEu4 via /r/csharp

Display a char array for editing and returning to controller? (MVC)

I have a char array that belongs to a view model I want to display like this in a view

 <div class="form-group"> @foreach (var item in Model.Items) { @Html.TextBoxFor(m => item) } </div> 

The problem is when I hit submit the array that comes back is null. What am I doing wrong? Here is the whole form.

@using (Html.BeginForm()) { <div class="form-horizontal"> @Html.ValidationSummary(true) @Html.HiddenFor(model => model.ID) <div class="form-group"> @Html.LabelFor(model => model.Name, new { @class = "control-label"}) <div class=""> @Html.EditorFor(model => model.Name) </div> </div> <div class="form-group"> @foreach (var item in Model.Items) { @Html.TextBoxFor(m => item) } </div> <div class="form-group"> <div class="col-md-offset-4 col-md-10"> <input type="submit" value="Save" class="btn btn-default" /> </div> </div> </div> 


The other properties do not come back null.

by Hi_Energy via /r/csharp

MVC string splitting in razor help

I have a string that I want to split in my cshtml file for individual editing.

I've tried this:

 <div class="form-group"> @for (int i = 0; i < Model.Items.Length; i++) { @i @Html.EditorFor(x => x.Items[i]) } </div> 

And this works here:

 <div class="form-group"> @Html.LabelFor(model => model.Items) @Html.TextAreaFor(model => model.Items) </div> 

But that second one has all the items in the string grouped together but I want to display them individually like my for loop does. But when the items return to the controller they come back as null. What am I doing wrong here? Thanks.

by Hi_Energy via /r/csharp

Responding to select list item selection in mvc

In you'd do this with the dropdownlist set to autopostback and then you'd have an event handler to do the work:

public void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { var SelectedItem = DropDownList1.SelectedItem; // do summing with the selection } 

Normally what I did in was to dynamically update the page based on this selection by loading data to a GridView or something and that's pretty much the functionality I want to replicate in MVC.

I have an @Html.DropDownListFor on my View and when a selection is made to it, I want to display, in a table, data related to the object selected from the DropDownList.

Typically I use ajax posts and I can do it the same way but how do I load the table with the new data exactly?

@model Ortund.Models.CreateReceiptReportViewModel ... @Html.DropDownListFor(model => model.StoreId, Model.Stores) <table id="receipts-table"> <thead> <tr> <td>Receipt #</td> <td>Value</td> <td>Date</td> </tr> </thead> <tbody> </tbody> </table> <script> $('#StoreId').on('change', function () { var StoreId = $(this).val(); $.post('/Invoice/SelectStore', StoreId, function (data) { if (!data.IsOk) { // report the problem } else { // we got a list of receipts back for the selected store, // load it into a table on the page somehow } }); }); </script> 

It occurred to me while writing this that If I get the receipt data back as an array of JSON objects I can loop through appending each new one to a new row in a table summing like this:

// this function will go into the else block of the previous jquery code function appendData(data) { // data contains an array of JSON objects that we're going to read data.forEach(function (item) { $('#receipts-table tbody').append('<tr><td>' + item.ReceiptNumber + '</td><td>' + item.Value + '</td><td>' + item.Date + '</td></tr>'); }); } 

The key here is that however the data is retrieved, the user is not to be redirected, but instead the View should just be updated seemlessly.

Think my code here will achieve this?

by ortund via /r/csharp

Turn off error for excessive at sign nesting in razor template?

It seems like a poor design decision on microsoft's part to make the following an error in your razor template:

@foreach(var x in list) { @if (x == null) { <my new text> } else { @x } } 

the page will render with an error saying "UNNECESSARY @"

Is there a way to disable this error?

it's easier to identify code vs text when there is @ rather than using VS syntax highlighting to point it out for you.

by jewdai via /r/csharp

Head First C# 3rd Edition with Visual Studio 2015 Community Windows 7

Hi guys

I didn't know where to ask for help so please tell me if this is the wrong place to post. Thanks!

Anyhow, I got a new book called Head First C#. In the beginning of the book, they are telling me to use windows 8 blank app and everything else in the book is for win 8 but I am using Win 7. I googled for a solution and I found their PDF which should be for chapters 1, 2 and 10 if using Win 7. It tells me to use WPF too. So, if anyone used that book and used win 7 , is that the correct way to learn? Should I then look at the book and the PDF at the same time or only at the PDF for the chapters I need? Sorry if this doesn't make a lot sense but I would really need an answer.


by xFORCERx via /r/csharp