Saving Many to Many relationship data on MVC Create view

Edit: I’ve written this up in 3 blog posts with code part 1 sets up the solution and creates a new user part 2 adds the courses and saves them with the user profile part 3 allows editing and deletion of users and their courses Github source: https://github.com/cbruen1/mvc4-many-to-many I think you’ve strayed from conventions a … Read more

How to change type of id in Microsoft.AspNet.Identity.EntityFramework.IdentityUser

Using a Stefan Cebulak‘s answer and a Ben Foster’s great blog article ASP.NET Identity Stripped Bare I have came up with below solution, which I have applied to ASP.NET Identity 2.0 with a generated by Visual Studio 2013 AccountController. The solution uses an integer as a primary key for users and also allows to get … Read more

Differences between Html.TextboxFor and Html.EditorFor in MVC and Razor

The advantages of EditorFor is that your code is not tied to an <input type=”text”. So if you decide to change something to the aspect of how your textboxes are rendered like wrapping them in a div you could simply write a custom editor template (~/Views/Shared/EditorTemplates/string.cshtml) and all your textboxes in your application will automatically … Read more

How does RequireJS work with multiple pages and partial views?

Update – I’ve added an example of using RequireJS with modular HTML components. Build tool example included – https://github.com/simonsmith/modular-html-requirejs I have also written a blog article about this – http://simonsmith.io/modular-html-components-with-requirejs/ The approach of just using main.js for everything is probably more suited to a single page application. The way I’ve handled this situation is to … Read more

How to create custom validation attribute for MVC

You need to register an adapter for the new attribute in order to enable client side validation. Since the RegularExpressionAttribute already has an adapter, which is RegularExpressionAttributeAdapter, all you have to do is reuse it. Use a static constructor to keep all the necessary code within the same class. [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false)] … Read more