Archive | June 2013

Login failed for user “user”. Reason: The account is disabled (Microsoft SQL Server ,Error: 18470 )

Over the time, I have been using Windows Authetication to connect to my MSSMS (Microsoft Sql Server Management Studio). And since during installation I had not enabled Mixed mode authetication on the server, I got some issues.

  1. I could not connect using  Sql Server Authetication
  2. The ‘sa’ account was disabled.

For security reasons, the ‘sa’ account is usually disabled, as it is a well known SQL server account and its often targeted by malicious users. And so, be thoughful while enabling the ‘sa’ account. And its recommended that you use a strong password.

I thought to summarize the short steps I gathered on the internet into one post. So let’s go.

Enable mixed mode authetication:

  • Login in to the server using the Windows authetication.
  • Right click your server and go to Properties, the select the Security 
  • Under Server Authetication section, You will find that “Windows Authetication Mode” radio button selected.
  • So, your work is to select “Sql Server and Windows Authetication Mode” radio button


  • Then click Ok
  • Right click the server again and select “Restart
  • That is it! You have now enabled mixed mode authetication on you server.

Enabling the disabled account.

  • Login using windows authetication
  • Go to Security, then Login. You will find the disabled account with the a small red arrow beside them as below


  • Right click the login name and go to Properties
  • You should see something like this with “Disabled” radio button checked


  • You need to check the Enabled radio button like this


  • Restart the server.

Another easier way of enabling ‘sa’ account and set a password using query as shown below.

ALTER LOGIN sa WITH PASSWORD = 'you new strong password' ;

Thats  it! You have Mixed mode authetication and account enabled .

Happy reading!!

Bootstrap Support To Visual Studio 2013

At Build 2013 developer conference , Microsoft announced that it has added support for Bootstrap, the popular framework for responsive websites that was launched out of Twitter in 2011. Visual Studio 2013′s project templates use Bootstrap by default when you want to build a web app in Microsoft’s ASP.NET now. If you were already tired of seeing too many Bootstrap-based sites, chances are you will now encounter even more of them. 🙂

It makes sense to add Bootstrap to its developer tools for web apps. It is the most popular framework for building responsive sites and has the most active ecosystem of services around it.You can use Bootswatch to find Bootstrap themes to make your sites stand out a bit more. This isn’t directly integrated into Visual Studio, but it obviously just takes replacing a CSS file to change a Bootstrap theme.



Returning javascript from ASP NET MVC

I have seen developers wonder how to return javascript from the server and have executed on client in an ASP NET MVC application. Fortunately, we have JavascriptResult in the ASP NET MVC stack which is responsible for doing exactly this.  It will make your life easier, but I am not advocate for  this as there are better ways doing this using Javascript on the client.

Anyway, here is how you can go about this in a few short lines of code


@Ajax.ActionLink("display", "Display", new AjaxOptions())


@Ajax.ActionLink("checks", "Sample", new AjaxOptions())


public JavaScriptResult Display()


const string script = "$('#message').append('Display');";

return JavaScript(script);


public JavaScriptResult Sample()


string script = "var textboxvalue=$('#name').val();";

script += "$('#message').append(textboxvalue);";

return JavaScript(script);



1) Clicking on the first link will display Display in the message div.

2) Clicking on the second link will display mazhar in the message div.

Happy coding and see you here again 🙂

Comparing passwords using angularJS

While working on a single page application using AngularJs, I did come across a situation where I needed to compare and validate passwords. Using angular documentation site, I found that the answer to my problem was to use directives. With angularJs directive you have all the control about you HTML markup.  Directives are executed during DOM compilation allowing you to transform DOM or add new behaviours.

There are directives that are offered out of box, but that does not mean you can not implement yours.  Some of the points you should have when implementing your directives include:

-Directives have camel cased name e.g ngBind. The directives can then be invoked by translating the camel case name into a snake case with special characters like – or _. Optionally you can prefix the directive with x- or data- to make it HTML validator compliant. This is seen on the custom directive I have worked on here.


<input bs-password-validator="password" ></span>

-AngularJS have restrictions which are a subset of EACM which provides restriction to specific declarations style. Omitting means that the directive will be allowed on attributes only. They are as follows:

  1. E-Element name <my-directive></my-directive>
  2. A-attribute <div my-directive=”expression”></div>
  3. C-class <div class=”my-directive:expression;”></div>
  4. M-comment <!–directive: my-directive exp –>

Without further ado, lets dive to the main topic of the day.  I started by adding html markup  as shown below

<span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: 13px; line-height: 19px;"><div></span></pre>
<div class="container" style="padding-top:100px">
 <div class="content">
 <div class="wrapper">
 <div class="proper-content">
 <form class="form-horizontal" name="registerForm" data-ng-controller="testCtrl" novalidate>

<div class="control-group">
 <label class="control-label" for="password">Password</label>
 <div class="controls">
 <input type="password" name="password" placeholder="password" id="password" data-ng-model="account.Password" required />
 <span class="text-error" data-ng-show="registerForm.password.$dirty && registerForm.password.$error.required">Password is required</span>


<div class="control-group">
 <label class="control-label" for="repeatPassword">Confirm Password</label>
 <div class="controls">
 <input type="password" name="repeatPassword" id="repeatPassword" placeholder="repeat password" bs-password-validator="password" ng-model="account.ConfirmPassword" required>

<span class="text-error" ng-show="registerForm.repeatPassword.$dirty &amp;&amp; registerForm.repeatPassword.$error.required" style="display: none;">Repeat password</span>
 <span class="text-error" data-ng-show="registerForm.repeatPassword.$dirty && !registerForm.repeatPassword.$error.required && registerForm.repeatPassword.$error.repeat" style="display: none">Fields are not equal!

 <div class="control-group">
 <div class="controls">
 <button class="btn btn-primary" data-ng-click="SaveUser()">Save</button>

My directive looks like this:

angular.module('test.directives',[]).directive('bsPasswordValidator', function () {</pre>
return {
 require: "ngModel",
 link: function (scope, elem, attrs, ctrl) {
 var otherInput = elem.inheritedData("$formController")[attrs.bsPasswordValidator];

ctrl.$parsers.push(function (value) {
 if (value === otherInput.$viewValue) {
 ctrl.$setValidity("repeat", true);
 return value;
 ctrl.$setValidity("repeat", false);

otherInput.$parsers.push(function (value) {
 ctrl.$setValidity("repeat", value === ctrl.$viewValue);
 return value;

<span style="font-family: Consolas, Monaco, monospace; font-size: 12px; line-height: 18px;">


In angular a controller is a javascript type that is used to make instances of the Scope, and this excludes root scope (more about scope to come).  There are mainly two uses of controllers:

  1. Set up the initial state of a scope object
  2. Add behavior to the scope object

So here is the my test controller and application set up

function testCtrl($scope) {
 $scope.SaveUser = function () {

 $scope.registerForm.repeatPassword.$dirty = true;
 $scope.registerForm.password.$dirty = true;

 if ($scope.registerForm.$valid && $scope.registerForm.repeatPassword.$valid) {
<!--call your services after here-->

If you have followed and done everything correctly you should be able to get the following screen if you type mismatched passwords.

And there you go.This code is just for demonstration, and so where I would prefer if you can separate directives into there own directory.

And your comments are highly appreciated, and its the only way to know you were here 😉

Happy coding and welcome back!! 🙂

Sample code can be found here 

What’s angularJS??

This post is the first in the series of learning and understanding the in and outs of angular js, comparison to other javascript frameworks. But for us to learn angular we need to know what is about and what problem it is trying to solve.

AngularJS is an open-source  framework, maintained by Google, that assists with running what are known as SPA . Its goal is to augment browser-based applications with MVC (Model View Controller) capability, in an effort to make both development and testing easier.

The definition from angular website is- Is a structural framework for building dynamic websites. By dynamic website, it means a website where the content is not fixed.  The content that is shown on page is based on the user selection and/or programmatically driven.

With angular,HTML is the templating language and enables you to extend HTML using directives.  Angular supports the following:

  • Data binding as in {{}}.
  • DOM control structures for repeating/hiding DOM fragments.
  • Support for forms and form validation.
  • Attaching code-behind to DOM elements.
  • Grouping of HTML into reusable components

Out of box, angular provides all the functionality required to build simple CRUD application which include templating directives, data binding, form validation, routing and dependency injection.

It also good to mention that angular js is not meant for all applications. Angular was designed with CRUD applications which makes quite a good number of application running today. So lot of consideration has to be made as to when to use angular or other libraries like Jquery.

Just to point some of the feature that are provided by Angular JS,

Databinding: This feature enable an automatic update of the view whenever the model changes and vice versa. This two way data binding its most notable feature and reduces the amount of code written by releaving the server from templating responsibilities. The templates are rendered in plain HTML according to data contained in the scope

Controllers: By using controller you explicitly express yourself in a clean,readable and maintainable way without any boilerplate, registering callback or even watching model changes. Controller are the behavior behind the dom manipulation. This encourages bootstrapping and rapid prototyping of web applications.

Directives: They help extend HTML specific to your application needs. You also use directives to create reusable components that may involve hiding complex DOM structure,CSS and behaviour

Testability: It encourages behaviour view separation, coming with pre-bundled with mocks with lot of dependancy injection involving for managing dependancies.

Dependency Injection: Simply, this is a pattern which is often used in infrastructure components and which ensures that one particular component does not create references directly to other components. Instead of direct instantiation every component will references to required other components  as parameter to there constructor. With this, angular this allows us to do like so:

function userCtrl($scope)

In this case we dont really care where the $scope is coming from. In future post we will look at the function of $scope.

AngularJs has some distinct compared to backbone  in terms of data binding,REST and templating which includes:

Whereas AngularJS supports two way binding, backbone relies heavily on boilerplate code to harmonize its models and views

Backbone communicates well with Restful backends, while angularJs’ $http service is more flexible connecting remote server either through a browser XMLHttpRequest object or via JSONP

In terms to templating, AngularJS users a combination of customizable HTML tags and expression while backbone.js uses different templating engines. e.g underscore.js

Notification area icons missing.

While working today, I realized that some icons that a appear on my notification area have disappeared. I noticed I can hear skype alerts but could not find the skype icons on the tray. Don’t make a restart as I did, since I have researched on the internet and found a consolidated solution for you which will not require a reboot. The solution is not specific to windows 8, as you can follow the same for windows 7.

I found the issue to be caused by various problems, and one that happened to be the cause on my machine was corrupted tray icons profiles. Follow the following steps to resolve the issue:

  • Press CTRL+R to open the run dialog
  • Type regedit


Press OK, and if the user account  control appears click ‘Yes’.

Find the following key on the left of the window that appears ‘HKEY_CURRENT_USER’

Below it click the Software then Classes, then Local Settings, then Software,Microsoft,Windows,Currentversion, then TrayNotify. On the right press CTRL and highlight IconStreams and PastIconStream, then right click them, then click delete. This will open “Confirm Value Delete” with the following messageDeleting certain values could cause system instability.  Are you sure you want to permanently delete these values?“. Click “Yes”.

full path

Now start task manager by using CTRL+SHIFT+ESC.Choose the Process tab,  Right click windows explorer process and select restart (A new feature for windows 8). If you are on windows 7 then do the following.

Right click on ‘explorer.exe’ and select” End Process”

A “Windows Task Manager” box will open and ask, “Do you want to end ‘explorer.exe’?”, “If an open program is associated with this process, it will close and you will lose any unsaved data.  If you end a system process, it might result in an unstable system.  Are you sure you want to continue?” (<Do not worry> you will be fixing this in the next step) Now click ‘Yes’

Now select the ‘Applications’ tab in “Task Manager”, in the bottom right hand corner, select ‘New task…’ and type ‘explorer.exe’ then click “Ok”

Explorer will now reboot and your icons should return.  *Note: You may need to reset your preferences for each icon by going back to your “Notification Area Properties” because it will reset most of them to the default status”

%d bloggers like this: