Friday, April 30, 2010

Google Map API V3 vs V2

Adding Marker in V2:
map.addOverlay(marker);

Adding Marker in V3:
marker = new google.maps.Marker( { position: point, icon: icon1, title: sTitle, map: map } ) ;

Removing Marker in V2:
map.removeOverlay(marker);

Removing Marker in V3:
marker.setMap(null);

Actually there are many more difference, but this post only highlighted basic one.

Wednesday, April 28, 2010

RadWindows pop up position

Want to control your radwindows pop up position, check out this post to save your life.

padding zero

Sometime when you need to append padding zero for a numeric figure. e.g. 0001, 0002 .

You might think to write your own 'sweet' logic to format the string. The good news is, .net out of the box gives you this feature.

string.Format("{0:00000}", yourIntegerValue);

unable to retrieve textbox value in server side when textbox is set readonly

One of the common UI design is to have a couple of textbox and you might want to prevent it from user modifying the value. And the easiest wayout is to set the textbox as readonly or disabled.

Unfortunately, you wont be able to get these 'disabled' or 'read-only' textbox value from server side.

One of the workarounds is to set the readonly condition during runtime instead of design time in asp.net page.

txtbox1.Attributes.Add("readonly", "readonly");

Page load event is fired twice with user control

One very strange behaviour that i noticed is that, page load event is fired twice. It started with page load and then followed by postback.

What I have:
1. Ajax Page
2.User Control
3.Asp.net C# page

After going through many testing and debugging, i realize that after setting the auto event wire up as false, everything is back to 'normal'.

To know which control trigger the postback, apart from using ___EventTarget to track, refer to this post, it contains a more comprehensive approach.

Page AutoEventWireup="false"

Thursday, April 22, 2010

Global RESX for chinese language

You might encounter the following error when you try to use chinese RESX file.

The namespace 'Resources' already contains a definition for 'Resource' Resource.CN

the reason is because the culture info is wrong.

refer to this post for more info. For basic knowledge, refer to this post

Animated scroll to anchor/id function with jQuery

This feature is useful especially when you need to maintain the page position after browsing from other pages.

A quick win will be using anchor in the url, but the catch is if you are using controls like telerik grid ajax postback, the anchor point #XXX in your url will be subtracted and you won't be able to do what you want.

One more point is that it is good to use this function in $(document).ready(function ()) instead of pageLoad() so that it only move to your position once when page is loaded not ajax postback.

checkout this blog for more information.

Tuesday, April 20, 2010

vss 2005 on vs 2010

Before you get your hands dirty on vs 2010, make sure you have the patch to make vss 2005 works with vs 2010, or else you have to setup TSF.

Download this patch.

Thursday, April 1, 2010

label on googlemap marker

This open source for labeling on googlemap marker is very useful.

Checkout the example from here, where you can inject html code to show your label.