Category Archives: Miscellanous

This would contain all post that can’t go to the other categories

Nuget uninstall package with dependencies

Thought i share a nice command of using nuget.

Let’s say you installed a package with a whole bunch of dependencies, but to found out later that that’s not the package that you want… how do we get rid of the package dependencies altogether without running uninstall-package command one by one.

for example, we’re installing jquery.ui.all package

look at that dependencies, after the painful wait due to my poor internet connection, i found out that i just need the jquery.ui.core package Sad smile

And i got all this packages installed

now, instead of running uninstall-package to each of dependencies

we could instead run

and that nice command take care it all

Happy new year 2012

Happy new year everyone!, this post arrive late Sad smile, well can’t help it since I got internet issues lately..

A lot of things happened for me in 2011, I got my first MCTS certification on web application using .NET 4, moved to a new boarding house with my wife, got a new job.. still in Bali though.

While some people on new years night go out partying or just hang out with friends, my wife and I decide to spend the night at Sanur beach. So we drove around 30 minutes away from home to get there, it was so crowded, a lot of people seems to had the same idea Smile. But we finally found a nice spot, where we spend an hour there watching the fireworks, to bad we didn’t bring any camera though, it was so beautiful.

Usually people make their new year’s resolution, well I got mine too.. one of them is to be able to post in this blog more frequently, looking back I only have around 6 post total in 2011 which probably because I think I should make a post related programming. Well.. that didn’t work too well for me, cause I didn’t know what to write, so hopefully I can post more frequently from now on even though is not about C# or ASP.NET.

Realtime web application with SignalR

A couple of weeks back i got a task to develop a chat application for an existing application that we have. The idea was so that the existing members could chat with each other without requiring any external IM services such as YM, Skype or MSN messenger. Seems quite simple.. well let’s see about that.

I did some research on how would be the best way to do this, there are a couple of ways that I found:

  1. AJAXpolling
  2. Comet/ AJAX long polling
  3. HTML 5 Web Socket

AJAX Polling

Before AJAX, websites page where not as interactive as of now, imagine that you open your favorite news site and then you got a list of news up until that time displayed on the page, left the tab open for an hour, and if you go back to that tab and need to see if there’s any new news since you left you need to refresh the page. Well with AJAX, a JavaScript could run in the background firing every n minutes to check if there’s any new data and display, this approach is called AJAX polling.

Using this idea of AJAX polling, people start to experiment on creating a real-time apps for web application such as chat application. The drawback of it is because it check to the server every n seconds/minutes it will put the server under heavy load, and imagine that if you have hundreds or even thousand users using the chat application and each of them do a check on the server to see if there’s any new data.. it will be a nightmare.

Not to mention the bandwidth consumption that this approach uses, people that see the weakness of this approach then seek a better approach

Comet / AJAX long polling

It’s a method, improvement if you like, from learning the weakness of AJAX polling, the idea of Comet is the client browser maintain a persistent connection to the server, and instead of the client checks every n second/minutes to the server to check new data, the server itself will tell the clients if there any new data and sent it to them.

HTML 5 Web Socket

This is a new feature in HTML 5 to provide a real two way communication between server and client, we don’t need to any workaround such as AJAX polling or Comet to create real-time apps it will natively provided by the browser as a feature of HTML 5. So as long the client’s browser support it and the server also support it we all set to go.

Back to the chat application, after taking a look at the available approach it seems that Web Socket would be the way to do it.. however currently –at the time of writing- it’s not supported by IE 9, even though FF7 and Chrome 15 does support it the IIS doesn’t support the Web Socket protocol yet.. bummer. So it seems i at this point i could only use Comet to develop my chat application.

Here’s where SignalR come to action, SignalR is async signaling library for .NET to help build real time web application. It’s an open source library under MIT license that’s developed by Damian Edwards and David Fowler, folks from Microsoft. It’s very easy to use, here an example taken straight from the documentation page.


Go to NuGet and install the SignalR package into a WebApplication:


Create a class the derives from Hub:


Javascript + HTML

If you didn’t notice, in the JavaScript code above it assign a click event handler to button with id broadcast which call a server method Send in Chat class.. and if we take a look at the Send method it will trigger the JavaScript addMessage() function for all connected clients. Pretty awesome isn’t it, this approach make it easy for client and server to communicate since they can call each other methods.If you run this code in multiple browsers and try it you will notice that if you press the broadcast button in one browser, then all the browser will all get the “Success!” message, a simple example of SignalR broadcast capability.

The other awesome thing about SignalR is that it will support Web Socket when IIS supports it, so at the moment i could just develop my chat application, and when IIS does support Web Socket, presumably on IIS 8 and .NET 4.5 i could just update the transport mechanism from Comet to Web Socket, and from what i read on the documentation page this could be done by just setting a single property, awesome !

Edit: Paul Batum has made a nice article of using Web Socket in Windows 8 developer preview with some example including chat.

The SignalR team hang out on, you’ll notice that it’s a chat application Smile, previously this chat app is meant to be an example for SignalR,  however with people keep adding new features into it, it slowly becomes a rich chat application, another good thing about open source. So if you want to know more about SignalR, download the source code at,  got any question or suggestion just go to their chat room, the nice folks there will help you.

Failed to load viewstate. The control tree into which viewstate is..

I got this error message when i was working with dynamic control earlier. It seems this exception is thrown when some control in the control tree can not successfully load it’s viewstate.

Let’s take a look at the code,

i created a dynamic list view, set the templates and add the listview to a placeholder control. So far everything works fine, i can add a data and it display it, delete also works but the problem arise when i tried to edit the item. Let’s take a look at the item template and edit template

It’s pretty straight forward, i have a literal control that display the value in view mode and a texbox control to display the value in edit mode. But everytime i try to edit it i got the same error again and again. And then a thought cross my mind.. what if i set all the controls in the item template and edit template but control their visibility property. Will that do the trick, let’s see..

Above is the modified item template, i include all controls that are used in both item template and edit template and basically just handle their visibility property. The edit template has simillar contruct but with different controls being hidden, you get the idea. And so.. compile, run the code.. fingers crossed.. and it works!. It has the same control hierarchy when on view mode and edit mode but display different controls, i guess using dynamic controls can be quite tricky.

Hope this helps.

Using Sql Compact 4 in WPF Application project

Earlier today, i’m having trouble generating database model using Entity Framework and SQL CE 4 in WPF Application project.

after googling around, it seems there’s quite a few people that’s having the same problem, it’s a different story if you’re using it in a web application project, there’s a selection for SQL CE 4 when you’re trying to generate database like shown below.

here’s the workaround on getting the EF play nice on WPF app project:

    1. create a new WPF app project
    2. right click the project and select add new item
    3. choose sql compact 4
    4. right click the project and select add new item
    5. choose ADO.NET Entity Data Model
    6. on the EF Visual Designer, right click and choose Update Model from Database

notice that it doesn’t have SQL CE 4 as a data source

here’s what we’ll do

  1. right click the project and select add new item
  2. choose Application Configuration File
  3. open the configuration file, and add in this line below inside the configuration tag

notice the {EdmxFileName} and {EdmxContainerName} that i put on the connection string, fill it with the appropriate value.
now go back to the EF visual designer and choose Update model from database
now it will know the database that we specified in our application configuration file

Happy coding



How to deal with boredom in long term project

As an employee in an outsourcing company, we do not have the luxury to choose which project that we want to join.

Sometimes the project will run for a month, a couple of month or even years. the latter is especially true when handling a software that’s mature enough causing most of the developers involved in the project only have to maintain the software.

after a few month, reaching a year, boredom will surely creeps in the developer’s mind. this is understandable of course, having to deal with the same thing every day for the last x month/years everyone at some point will have that sense boredom.

as a developer there’s a couple of things that we can do to take our boredom away while keep upgrading our skills.

make a simple project, you determine the deadline, you determine the features, you determine the technologies to be used, make it fun, challenge yourself.

some project may not be accomplished, but that’s ok. learn from it, why you can’t finished it on time, or why you left it partway. is it because the design flaw, poor judgment on the technologies or just don’t have time to work on it.

every thing that you get from your simple project can benefit yourself in your professional life, it’s a valuable experience.

so get out there, and start making your simple project 🙂

Using Jquery UI Autocomplete to consume WCF Service

I had some problem when trying to use jQuery UI autocomplete to get the data from a WCF service, after browsing around i finally found a way to resolve it

In the jQueryUI autocomplete file:

  1. Change the code for jQuery UI autocomplete , by default it execute an ajax call with GET method, we need to change this to POST
  2. We need to change the default content type to “application/json”  or else there will be an exception when trying to access the WCF service
  3. The WCF service will try to deserialize the data that we sent and it expect the data that we sent is sent in JSON string format
    1. eq: {‘term’:’human’} and not ‘term=human’ to do this we can use JSON.stringify method that we can get from
In the WCF service file:

We need to decorate  our method with this attribute

The javascript code

The jQuery UI that i use is version v1.8.14

Good javascript habits for C# developers

I felt the urge to write this post after watching a certain video a couple days back, it was called Good javascript habits for C# developers the same as the title for this post. The presenter was Elijah Manor, a microsoft MVP that works at .appendTo(). It was about what common mistakes that C# developers made when dealing with javascript, some of that common mistakes that he mention would explain why i sometime wonder why this javascript function is not working properly while at other place it did. You’ll see what i’m talking about in after reading this post, hopefully this would help someone as it did help me.

Continue reading Good javascript habits for C# developers