Skip to main content

Posts

Showing posts from 2012

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 the project. TaaDaa!!! It

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.  

Pair class in .Net

Pair class in .Net is a utility class which allows to store two related objects in one Object. One of the most frequent use of this is while creating user controls with control state. You can see more information at http://msdn.microsoft.com/en-us/library/system.web.ui.pair.aspx

HotSpotMode enumeration

HotSpotMode enum has following values Inactive NotSet Navigate Postback You can set HotSpotMode either on ImageMap control or individual HotSpot control for the ImageMap. If you specify it on ImageMap only, all the HotSpot controls interhit the behavior. All HotSpot controls must be set to NotSet to inherit the behaviour. If you specify NotSet on ImageMap and HotSpot control, the default behaviour is Naviagate. If you specify NotSet only on HotSpot, it works out the behaviour based on the setting on ImageMap. The setting on HotSpot takes precendence over the ImageMap. The settings take precendence in the order they are specified. Hence you should specify inactive map before you specify active map to create complex mapping.