Skip to main content

Posts

How to detect HTML5 support for a browser?

HTML5 has introduced lots of new cool  tags . Not all the browsers support all tags and also the implementation of these tags may be different for each browser. HTML5 specification defines the functional aspects of these tags and not the implementation. Also the general concensus is that by 2022 all browsers will support all new features of HTML5. Of all the modern browsers, Chrome seems to have implemented most, if not all, featutes of HTML5. IE9 supports few. Firefox sits in between. So as a developer how do you make use of the cool HTML5 features without causing any compatibility issues with existing browsers? Traditionally developers have used User Agent to detect browser type and use the features accordingly. However these days, you can easily change a User Agent by using addons in your browser. So you need a more robust way to detect the features supported by the browser as the same engine of two different versions of a browser mig...

Jump start HTML5 with CSS and Javascript

Microsoft is giving away a free course (an accelerated one rather than full 5 day course) and a voucher to take exam 70-480 which prepares you for MCSD certification. You can find free voucher and course here http://www.microsoft.com/learning/en/us/html5-offer.aspx . I have started preparing for this exam. I will be using mostly online resources and will add posts here as I go along.

How to test Mobile Web Application locally

Recently I started building a mobile Web application. Now I wanted to test how it looks on a mobile device like an iPhone or Windows phone browser. One option was to use simulator or change user agents in browsers on PC. You can easily do this with Developers tools in Firefox. Another option is to setup you application as a website in local IIS. If you are running IIS on Windows 7, start IIS Manager and create a new site. Point this site to your local web application folder. Now add a binding to point local IP address of you machine (e.g. 192.168.1.1) to your web application. You can option local IP address by typing ipconfig on your command prompt. Now connect a mobile device to your local network over wifi. Try typing the local IP address of you machine in the browser. If you get message that page cannot be displayed, chances are that the firewall on your local machine is blocking incoming http request. To fix this, start Firewall on you machine and add a new incoming rule to ...

Free TFS service

Microsoft is giving free TFS service for upto 5 users. This is really useful if you are free lancer or like me have web development as a side hobby/business outside your main job. For more information, visit http://tfs.visualstudio.com/en-us/pricing/information/

Caching in Safari on IOS 6 for Ajax calls

When using caching for Ajax calls, the standard rule is to cache GET requests and not to cache POST requests. However Apple seems to have broken this rule in IOS 6 release. Safari seems to be aggresively caching in order to improve performance on iPad. We noted this problem when one of our applications started failing as it wasn't calling a webservice using Ajax. We couldn't replicate the problem on a PC. So after enabling logging for the webservice, we noticed that Safari wasn't calling the webservice after first call and caching the content. The logic Safari uses that if the parameters and the value of parameters is  same, then it will use cached reponse. We tried disabling the caching by setting response headers to prevent any form of caching. Safari ignores all caching headers (Thank you apple for deviating from standards...). The only workable solution is to set of the parameters which will have a different value for every request. We have used a timestamp. This...

Application Vs ApplicationInstance

Application refers to global application state in Classic ASP. Application is really a global dictionary object that was introduced in Classic ASP for lack of any global variables. ASP.Net uses ApplicationIntance property to refer to application instance that is processing current request. Application instances are thread safe hence it is not required to lock the non static members. ASP.Net has Application object purely for backword compatibility so that you can easily migrate a Classic ASP application to ASP.Net. It is recommended that you store data in static members of the application class instead of in the Application object. This increases performance because you can access a static variable faster than you can access an item in the Application dictionary. You can use following guidelines when accessing non static members in ASP.Net From the Global.asax, use the this or Me object. From a page, every page includes a strongly-typed ApplicationInstance prope...

Referencing COM Object from Visual Studio 2008/2010

Today I faced a very unusual problem. We have set of COM components which get installed on local machine by a set-up project. These COM components are referenced by .Net applications. Visual studio automatically creates COM Interop assembly in bin folder. So far so good. Recently there was a change to COM component whereby a new property was added. After installing the COM component I could see the new property in Object Browser in Visual Studio 2010. However it was missing in the Visual Studio 2008 Object browser. I tried removing reference to the COM object and adding again. Still it didn't resolve the issue. Went out for a Christmas meal. Had a very heavy meal and Yorkshire puddings at Toby's and a glass of Red wine. Came back. Looked at the project again. This time I removed the reference. Also I deleted the Interop files created by Visual Studio from project bin (debug/release) folder and obj folder. Added the reference again and compiled t...

Top Tip - Validating Dropdown control

Ian Haynes, ASP.Net in Expression Web MVP, has a top tip about validation controls. Validation on a drop down list At first glance it looks as though there is no way of adding the normal validation to a drop down list to indicate that a values needs to be selected. In fact it's very simple. Add a list item 'Select', set it as 'selected' and put it's value = "" Then add a RequiredFieldValidator to the drop list control. As no value is given for the 'Select' option, the validator triggers and your error message is shown.

MVC error Unable to cast object of type 'System.Int32' to type 'System.String'.

If you are getting following error while posting back data in MVC Unable to cast object of type 'System.Int32' to type 'System.String'. Check for the validation attributes on the number data types. If you have a StringLength attribute on a numeric datatype, MVC autobinding converts the field to a string and causes above error while autobinding. Instead use RegularExpression to limit numbers in a numeric field.