Friday, February 7, 2014

Knockout Date Format Extender

As you know Knockout is great on two-way binding and provides a clean mechanism for showing data on the page. There will be scenarios where you want to format your data to make it user friendly. This is especially true when you are showing dates. You don’t want to show the default javascript format to your users. You can certainly format dates while doing the databinding. But formatting dates inside your binding quickly becomes clumsy and sometimes you lose your two-way binding.

In this blog I will show you how to modularize the date formatting and use it throughout the application. Thanks to the Knockouts extenders which allows us to define our date formatting in an elegant way. If you are not aware of Knockout extenders, please check documentation on their site


Before getting into the extender, I want to tell you about a small javascript library, Momentjs, I use for all my date related functionalities. Momentjs is small javascript library for parsing, validating, manipulating and formatting dates. For more information check their website


Using MomentJS, I can do the date formatting to MM/dd/YYYY format by the following syntax.

    moment(newValue).format('L')

MomentJS provides several formatting options. For more information check their website.
Coming back to knockout extender, let’s create an extender called dateformat which format the observable with the specified format.

    ko.extenders.dateformat = function (target, format) {
        var result = ko.computed({
            read: target,
            write: function (newValue) {
                target(moment(newValue).format(format));
            }
        }).extend({ notify: 'always' });

        //initializing with the formatted value
        result(target());

        //return the new computed observable
        return result;
    };

We need to define this extender only once. In Durandal you can define it in the main.js.

This extender can be consume while defining the observable as below:

    var DateOfBirth = ko.observable(new Date('1/4/2000')).extend({ dateformat: 'L' });      

That’s all we need to do. The databinding in the view is same as earlier.

<span data-bind="text: DateOfBirth"></span>


You can use this dateformat extender throughout your website with different format options.

Wednesday, February 5, 2014

Refresh all Browser by Browser link

Browser link features are available in visual studio 2013 onward.

To Check this feature first Create project
Refresh all Browser by Browser link





You can follow below image to debug

Refresh all Browser by Browser link












You can select multiple browser as below by holding CTRL
Refresh all Browser by Browser link


















Now Press the Refresh button or press CTRL+ALT+ENTER all browser window will  refresh.


Refresh all Browser by Browser link













Source: http://www.asp.net/visual-studio/overview/2013/using-browser-link

Tuesday, February 4, 2014

jQuery Plugin to Create Quizzes-SlickQuiz

As we know that creating a quiz is really a complicated task. So help the developer and reduce the coding part we are going to introduce a jquery Quiz plugin...


Click here to check Demo
 
Download Zip File

Could not open a connection to SQL server – Fix Connection Problems of SQL Server

 SQL SERVER – Fix : Error : 40 – could not open a connection to SQL server – Fix Connection Problems of SQL Server

An error Occurred while establishing a connection to sql server.

Solution 1

Go to Control Panel -> Administrative Tools -> Computer Management : Open It
Expand Services And Application-> SQL Server Configuration Manager->

After this Sql server services restart it. then Check.

if it not work 
Check Aliases Option Under.
If you find any aliases for the SQL Server that you are getting problem. Delete it for time being and test it.

Suggestion 2:

Try checking these things,

1. Check SQL Server Browser service is running and is kept in automatic Start mode.

This can be checked by.

Start -> run- > type services.msc -> enter -> check for SQL Server browser service, and start if it is not running.

2. Under SQL Server Surface Area Configuration check if SQL Server allows remote connections, by default it will allow only local connections.

This can be checked by,
Login to Server ( Where SQL Server is installed )
Start-> allprograms -> Microsoft SQL Server 2005->Configuration Tools -> SQL Server Surface Area configuration -> Click Server Area configuration for Services and connections ->choose your sql server – remote connections -> on the right side, choose allow remote connections to this server and choose both TCP/IP and NamedPipes.

3. Or Check your Windows Firewall, if SQL Server is being blocked, try to disable Firewall and then connect if it works then problem could be WIndows firewall.

Suggestion 3:

There are couple of ways to troubleshoot this problem. The one you should use depends on how your databse server was configured and some other factors as well.

For example, if you configure the database engine to use dynamic port allocation, make sure that sql browser is runnning. SQL browser provides the connection information about the database engine to the the client.

If the sql browser is not running and you have restarted sql server and port 1433 is being used by other applications, database engine will be allocated a different port number. Imagine that the client has been configured to use port 1433 to connect and the database engine is using a different port number. The client wont be get the connections properties to the database engine from sql browser because sql browser is not running.

Monday, February 3, 2014

Frog Fu - Open Source Game

 Frog Fu is The Game for you and your family. Children love it! Parents enjoy it! The game takes you deep into a colorful cartoon world of the kung fu frog. Quality animations and rich graphics will quickly make you feel part of this wonderful world.

Frog Fu is iOS game written on C++ with OpenGL 2 now available as open source project on GitHub
Frog Fu - Open Source Game

You can find it on the App Store at: https://itunes.apple.com/us/app/frog-fu/id574269225?mt=8