Errata

ASP.NET MVC 5 with Bootstrap and KnockoutJS

Errata for ASP.NET MVC 5 with Bootstrap and KnockoutJS

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Printed Page 37
1st code block describing connection string

This is dev environemtn related - I can't say the book is wrong, but it won't work for my setup.

Using VS2015 Enterprise with SQL Server 2014 installed, "Data Source=(LocalDb)\v11.0;" didn't work until I changed it to "Data Source=(localdb)\mssqllocaldb;"

Taken from here: http://www.sqlcoffee.com/SQLServer2014_0010.htm

"On SQL Server 2014, The SQL Server team created "mssqllocaldb" as the default name for the automatic LocalDB instance. The name of the automatic LocalDB instance is no longer related to SQL Server version number (v11.0 = SQL Server 2012, v12.0 = SQL Server 2014). Thus, we should use "(localdb)\mssqllocaldb" as server name to connect to LocalDB automatic instance on SQL Server 2014, as shown b"low.

I suspect this will become the default auto-localdb name from now on and was not yet changed when written.

Paul Sturm  Jul 09, 2016 
Printed Page 73
Beginning of code sample after second paragraph

In this line

@Scripts.Render("~/bundles/jqueryval", "/Scripts/ViewModels/AuthorFormViewModel.js")

there should be a "~" at the beginning of the second path indicated.

"~/Scripts/ViewModels/AuthorFormViewModel.js"

If you hit F12 while creating a new author, you'll see a couple errors come up about not being able to find the file and not being able to create an AuthorFormViewModel object.

I only found this after starting on the changes to consolidate the create/edit views. I was able to create an author before then.

Enjoying the tutorial! Learning a lot! Thank you!

Jerry Altman  Jan 03, 2016 
Printed Page 74
Each of three instances of "@Html.EditorFor(...)" on the page.

@Html.EditorFor(model => model.FirstName, new ( htmlAttributes = new { @class = "form-control", data_bind = "value: author.firstName" } })

(Same for LastName and Biography.)

Visual Studio Express 2013 wouldn't accept the lines as written.

I adjusted the assigned value for @class as follows:

@class = "form-control data_bind=\"value: author.firstName\""

This seemed to work for me, but definitely post a more appropriate snippet if applicable.

Thanks! Am really enjoying the tutorial.

Jerry Altman  Jan 03, 2016 
Printed Page 95
Example 7-3 Example AutoMapper code

This really isn't an error but Jimmy Bogard has changed AutoMapper libray. It's no longer static starting it seems with version 4.2. I pulled his latest version (v5.1.1) via Nuget and couldn't get the code on page to work.

Had to use the following in all the spots where CreateMap and Map functions were used:
// For Automapper v5.1.1
var config = new MapperConfiguration(cfg => { cfg.CreateMap<Author, AuthorViewModel>(); });
IMapper mapper = config.CreateMapper();

db.Authors.Add(mapper.Map<AuthorViewModel, Author>(author));

-------------------------------------------------------------------------------------------

Also, this isn't an error but I found all the escaped double quotes very hard to follow and prone to typos. I created a constant in the HtmlHelperExtension to make the code cleaner and easier to read (at least for me) - see below:

public static class HtmlHelperExtensions // Class for Extension Method
{
private static string DOUBLEQUOTE = "\"";

/*
* Extension method BuildNextPreviousLinks - also private methods associated with this method
*/
public static MvcHtmlString BuildNextPreviousLinks(this HtmlHelper htmlHelper, QueryOptions queryOptions, string actionName)
{
var urlHelper = new UrlHelper(htmlHelper.ViewContext.RequestContext);

string myString = string.Format(
"<nav>" +
" <ul class=" + DOUBLEQUOTE + "pager" + DOUBLEQUOTE + ">" +
" <li class=" + DOUBLEQUOTE + "previous {0}" +DOUBLEQUOTE + ">{1}</li>" +
" <li class=" + DOUBLEQUOTE + "next {2}" + DOUBLEQUOTE + ">{3}</li>" +
" </ul>" +
"</nav>", IsPreviousDisabled(queryOptions),
BuildPreviousLink(urlHelper, queryOptions, actionName),
IsNextDisabled(queryOptions),
BuildNextLink(urlHelper, queryOptions, actionName)
);

MvcHtmlString mvcHtmlString = new MvcHtmlString(myString);

return mvcHtmlString;
}

Anonymous  Aug 17, 2016