Posts

Knockout.js binding syntax bind to root, self, current context

When using knockout.js  if your ViewModel is an array and you want to bind to the entire ViewModel, the syntax to bind to the ViewModel root, when the root is the current context: The XAML syntax equivalent when the DataContext is an array: ... Hope this helps, Aaron

ASP.NET MVC 4 SimpleMembershipProvider, WebMatrix WebSecurity CreateUserAndAccount Create New User SQL

---------------------- ASP.NET MVC 4 Membership Overview:  http://aaron-hoffman.blogspot.com/2013/02/aspnet-mvc-4-membership-users-passwords.html ---------------------- Using SQL Profiler, below is the SQL that is executed when the ASP.NET MVC 4 SimpleMembershipProvider's WebMatrix.WebData.WebSecurity.CreateUserAndAccount() method is called: Text below in bold is dynamic and represents the UserName and Password properties passed to the CreateUserAndAccount() method as well as the UserId generated as part of user creation. Similarly, the name of the UserId and UserName columns, and the name of the UserProfile table may also be different based on your specific configuration. exec sp_executesql N'SELECT [UserId] FROM [UserProfile] WHERE (UPPER([UserName]) = @0)',N'@0 nvarchar(23)',@0=N' UserName ' exec sp_executesql N'INSERT INTO [UserProfile] ([UserName]) VALUES (@0)',N'@0 nvarchar(23)',@0=N' UserName ' exec sp_executesq...

ASP.NET MVC 4 SimpleMembershipProvider, WebMatrix WebSecurity Login SQL

---------------------- ASP.NET MVC 4 Membership Overview:  http://aaron-hoffman.blogspot.com/2013/02/aspnet-mvc-4-membership-users-passwords.html ---------------------- Using SQL Profiler, below is the SQL that is executed when the ASP.NET MVC 4 SimpleMembershipProvider's WebMatrix.WebData.WebSecurity.Login() method is called: The UserName below (in bold ) is dynamic, it represents the UserName parameter passed to the Login() method. Similarly, the name of the UserId and UserName columns, and the name of the UserProfile table may also be different based on your specific configuration. exec sp_executesql N'SELECT [UserId] FROM [UserProfile] WHERE (UPPER([UserName]) = @0)',N'@0 nvarchar(25)',@0=N' UserName ' exec sp_executesql N'SELECT COUNT(*) FROM webpages_Membership WHERE (UserId = @0 AND IsConfirmed = 1)',N'@0 int',@0=1 SELECT m.[Password] FROM webpages_Membership m, [UserProfile] u WHERE m.UserId = 1 AND m.UserId = ...

Edit Default Visual Studio 2012 Item and Project Templates

After adding a new file or project within a Visual Studio solution there are certain settings that I always update.  Follow the steps below to edit the default templates so these settings become the default. Visual Studio 2012 Project and Item Template files are located here: C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ItemTemplates C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ProjectTemplates Add "public" to all new C# class files: Edit the Class.cs file by adding the word "public" in front of the word "class" The Class.cs can be found here: C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class\Class.cs After you're done, it should look like this: using System; using System.Collections.Generic; $if$ ($targetframeworkversion$ >= 3.5)using System.Linq; $endif$using System.Text; $if$ ($targetframeworkversion$ >= 4.5)using System.Threading.Tasks; $e...

JavaScript Null Checking, Undefined and ! Unary Operator

Image
Google searches of "JavaScript null check" and "How to check for null in JavaScript" were returning results that left something to be desired in my opinion, so I compiled this list. See the code live here: JsFiddle:  http://jsfiddle.net/aaronhoffman/DdRHB/5/ Code also available here: https://github.com/aaronhoffman/utils/blob/master/JavaScript/NullChecks.js Comparison Chart: Hope this helps, Aaron p.s. I used a great tool Regex Pixie  http://www.regexpixie.com/  by StoneFinch  http://stonefinch.com/  to generate most of the code in this example (disclaimer, I currently work for them, however I would never promote a tool I don't use myself.)