Saturday, February 8, 2014

using Google map inside update panel

I  have tried to use the Google Map inside an updatepanel and it ended up giving me strange JavaScript error "javascript - Unable to get value of the property 'offsetWidth': object is null or undefined ".
After some research I found that it occurred when you have build your map when the Maps API JavaScript has not loaded. I as able to solve the issue when I load the map as displayed below.

 <script type="text/javascript">
        function initialize() {
            var mapOptions = {
                zoom: 6,
                center: new google.maps.LatLng(7.0000, 81.0000),
                mapTypeId: google.maps.MapTypeId.ROADMAP
            }
            var map = new google.maps.Map(document.getElementById("googleMap"), mapOptions);
        
            });
        }

        function loadScript() {
            var script = document.createElement("script");
            script.type = "text/javascript";
            script.src = "http://maps.googleapis.com/maps/api/js?key=<your_api_key>&sensor=false&callback=initialize";
            document.body.appendChild(script);
        }

        window.onload = loadScript;
    </script>

for more information refer http://stackoverflow.com/questions/5478450/google-map-error-a-is-null

Cheers
Samith

Saturday, January 11, 2014

Using Google MAP control in Asp.Net

There are various Google MAP controls available that can be used with Asp.Net. Listed below are few of popular Google MAP controls available.

1) Subgurim google map
2) Artem google map
3) Reimers google map

 I have tried using all of the above controls but my exact retirement could not be achieved. My objective was to get the latitude  and longitude of the clicked location. The problem was I had two map controls on the same form and it seems if two map controls are used on the same form, click event of the second control does not get fired for some reason. I could not find the reason for this to occur and finally ended up using google API provided in w3shools which solved my problem.

cheers
Samitha


Thursday, December 19, 2013

Change Asp.net Ajax tab page header from javascipt

This is not as straightforward as you might have thought. To access the tab pages use get_tabs()[indexOfTab] as shown below.

$find('ctl00_cphMainContent_tc1').get_tabs()[0]) ; // tab 0
$find('ctl00_cphMainContent_tc1').get_tabs()[1]) ; // tab 1

To set the tab header use the _header of the tab
 $find('ctl00_cphMainContent_tc1').get_tabs()[0]._header.innerHTML='Tab 0';
 $find('ctl00_cphMainContent_tc1').get_tabs()[1]._header.innerHTML='Tab 1';

Cheers
Samitha

Saturday, December 7, 2013

asp.net 4.0 mobile development

With the release of asp.net 4.0 and MVC 3.0 there has been a major changes in the mobile development. Following whitepaper discusses in detail how you would develop mobile web pages with asp.net 4.0 and MVC 3.0 .

http://www.asp.net/whitepapers/add-mobile-pages-to-your-aspnet-web-forms-mvc-application

cheers
Samitha

Saturday, November 16, 2013

Checkboxlist checkbox items acess from javascript

If you want to iterate through Checkboxlist  check box items it not as straightforward as you might have thought.

The trick is to access the check box items rendered as labels as shown below

 var chkBoxList = document.getElementById('<%=chkList.ClientID%>');

                var checkboxes = chkBoxList .getElementsByTagName('input');

                for (var i = 0; i < checkboxes .length; i++) {
                    var checkItem = checkboxes [i];

                    var label = checkItem .parentNode.getElementsByTagName('label');
                     //checked item
                      if (checkItem .checked) {
                           ...
                        }
                       //access checkItem text
                        label[0].innerHTML='';
                    }

                }

cheers
Samitha

Saturday, October 19, 2013

Visual Studio 2013 Reased


Microsoft Announces offical release of  Visual Studio 2013 and offerd key features including

  • Better Productivity 
  • Windows 8.1 App Development
  • Debugging improvements and more...
 
More Info and downoload
http://www.microsoft.com/visualstudio/eng/visual-studio-2013#story-2013

cheers
Samitha