"Done is better than perfect."


Print part of a webpage with Javascript

PrintForm = function (strid) { var prtContent = document.getElementById(strid); var WinPrint = window.open(”, ”, ‘letf=0,top=0,width=480,height=400,toolbar=0,scrollbars=0,status=0′); WinPrint.document.write(prtContent.innerHTML); WinPrint.document.close(); WinPrint.focus(); WinPrint.print(); WinPrint.close(); prtContent.innerHTML = strOldOne; } Here’s the webpage, the printable area must be inside a div: <div id=”divPrint”> SAMPLE CONTENT </div> <input id=”btnPrintBottom” type=”button” value=”Print” onclick=”PrintForm(‘divPrint’)” />




Preserve objects over postbacks with JSON serialization.

Let’s suppose we have a website in load balance without sticky sessions, here’s an easy way to mantain objects over a postback. Using the JavaScriptSerializer class it is possible to serialize objects in the tiny JSON format, store them in a hidden field and retrieve them after the postback. public class JSONUtils { public static […]




Great ASP.NET MVC step by step guide.

On the Microsoft ASP.NET web site there is a very well done step by step guide to build an MVC 2 website. The creation of the site covers most of the topics related to this relatively new (in .Net) technology, here’s the link : http://www.asp.net/mvc/tutorials/mvc-music-store-part-1.  




C# Text Encoding and Transcoding in few steps

While developing on a tool that to allow user to enter a message in whatever language and to print it I discovered that I didn’t know enough about character encoding. Character encoding is is a set of unique rapresentations called character: they can be the 26 letters of the English alphabet or even the set […]




Repeat a char for a number of times

I wasn’t aware there is a constructor for the String type that allow to insert the number of times we want a character to be repeated: //expected: “AAAAA” String result = new String(‘A’, 5);




Resize image to be web friendly

There’s already a post about this subject on the blog but it is in italian, I want to propose it again because the task of resizing and slim the pictures we got (for facebook, for our blog) is a common task we are all used to. Here’s the code and a small console app you […]




WF 3.5 and SendActivity issue.

I am working on some .net 3.5 workflows, I’ve read that a migration to the fourth version of the framework is strongly reccomended for reasons spacing from perfomance to a better integration with WCF. Anyway, I was not able to invoke a WCF having a basicHttpBinding, in order to get it working I had to […]




Increase message size in WCF

During the testing of a WCF service, for certain requests I started to get the following error : “The maximum string content length quota (8192) has been exceeded while reading XML data”. While on a classic asmx web service in order to specify the maximum lenght for a request with the tag <httpRuntime> in WCF […]




WCF – Merge WSDL in a single file

It can happen that old clients dislike the way WCF separate WSDL descriptors. By default, a WCF service contains the full WSDL in an external “link” specified by the wsdl:import directive. If I browse the following service http://localhost:8695/GiftMessageService.svc?wsdl i’ll get a description of the service (like ports, address) but nothing about the soap actions and […]




Two easy ways to expose a WCF as a WebService (even asmx)

Assuming we’re all using Visual Studio 2010, start by creating two projects: a WCF Service library project and a WCF The service library will contain the contracts and their interfaces with all the service attributes while the service application will be the project exposed by our web server, it will have the *.svc and *.asmx […]