Showing posts from 2013

JSON.stringify causing problems with decimal values in MVC Action parameters

PROBLEM You may have noticed some time your MVC web site behave crazy when you are passing decimal values to a action. This decimal problem arises if you are using " JSON . stringify " to get JSON string to send with HTTP POST to a MVC controller action. What causing the issue is  JSON . stringify  will behave as follows. 15.123 => 15.123 15.00 => 15 EX : {a:15.123, b:15.00} => "{a:15.123, b:15}" When this json string reach MVC default model binder, it will convert 15.123 parameter as a decimal and 15 into a integer or long according to your value. SOLUTION 1) Convert your decimal values to string before you pass it to  JSON . stringify 2) Use a custom model binder for decimals (more info here  : posted by Josh) using System; using System.Globalization; using System.Web.Mvc; public class DecimalModelBinder : IModelBinder {     public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)     {  

Problem with adding Service Reference in VS2010

Error : Metadata contains a reference that cannot be resolved Some of you may have faced the same issue of adding service reference to a web service in VS2010. I had the same problem with VS2010 when I try to add service reference, it gives me an error "Metadata contains a reference that cannot be resolved". But if I try to access the WSDL using a browser, I can see that WSDL is showing perfectly. For some reason (specially the web service is not in your network) this VS tool unable to generate web service proxy class. If you have same situation, you can use "svcutil" comes with the VS tools. Just open a VS command prompt and execute the following command (format the command according to your preference) svcutil /out:C:/MyProxyClass.cs /namespace:*,MyProject.Services.DataService You have to replace your web service url, class file name and namespace. The proxy class generated from this is exactly same as the one is

Show Jquery UI Dialog on the centre of the screen

Use following on the JQuery UI dialog option when you create the dialog.         open: function (event, ui) {             $('position', 'fixed');             var winheight = $(window).height();             var winwidth = $(window).width();             var diaheight = $(;             var diawidth = $(;             $('top', ((winheight-diaheight)/2).toString() + 'px');             $('left', ((winwidth - diawidth) / 2).toString() + 'px');         },

Rounded Corners in IE 6,IE 7,IE 8 (border-radius)

As we all know that Firefox, Safari and Chrome support rounded corners. But IE 6, IE 7 and IE 8 doesn't support this through css. CSS3 comes with border-radius property which provide this rounded corners. I spent days to find a way to make IE to have rounded corners through css. Finally found a nice implementation in . Below is the sample usage to make IE support rounded corner through CSS. Styles : .roundedborder {     behavior: url(pathfrompagetohtcfile/;     position: relative;     background: #FFF; -moz-border-radius: 5px 5px 0px 0px;  -webkit-border-radius: 5px 5px 0px 0px;  border-radius: 10px 10px 0 0; } Notice that we need a trick that is file which is the magic here. You can find the htc file link at the end of this article. This file is understandable by IE and it does the job we required. In order to work this trick, you need jquery also. HTML : <div class="roundedborder" style="height:50px;">