Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Javascript
Hi,
 
I have a button control as
 
<asp:Button runat="server" ID="btn" Text="OK" Width="100PX"  OnClientClick="return changeMessage();"/>
in aspx page.
 
In head section of page add a external js file using,
 
<script language="javascript" type="text/javascript" src="../Script/Map.js"></script>
 
Map.js content as below,
 
----------------------------------
 
//Function displays the google map
function initialize() {
    
   
    var mapOptions = {
        zoom: 6,
        center: new google.maps.LatLng(8.558058925477096, 76.87785568237302),
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        navigationControl: true,
        navigationControlOptions:
    {
        style: google.maps.NavigationControlStyle.ZOOM_PAN
    },
        scaleControl: true,
        DoubleClickZoom: true,
        draggable: true,
        streetViewControl: true,
        draggableCursor: 'pointer'
    };
 
    map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
    map.setZoom(16);
    
    //document.getElementById('messageDisplay').style.visibility = "hidden";
}
 

 
//Function handle the click event
function route() {
   
    alert("hai");
}
 
------------------------------------------------------------------------------
 
Then, in aspx page i call function 'route()' in Map.js inside a <script> tag as below
 
--------------------------
 
<script language="javascript" type="text/javascript">
 
    function changeMessage() {
 
        if (document.getElementById("MainContent_btn").value == "OK") {
            document.getElementById("MainContent_messageLabel").innerHTML = "Click START to start drawing route";
            document.getElementById("MainContent_routetxt").style.visibility = "hidden";
            document.getElementById("MainContent_btn").value = "START";
            return false;
        }
 
        //Calling route() in Map.js

        if (document.getElementById("MainContent_btn").value == "START") {
 
            route();
        } 
    }
 
</script> 
But it give error as ,
Microsoft JScript runtime error: Object expected.
 
what is wrong in code?..
Posted 16-Oct-12 20:18pm
hasbina1.2K
Edited 16-Oct-12 20:22pm
57.4K
v3
Comments
Arunprasath Natarajan at 20-Oct-12 7:32am
   
I guess still few more codes are missing. Kindly provide the same.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 534
1 Gihan Liyanage 298
2 ChintanShukla 295
3 RyanDev 250
4 Richard Deeming 250
0 Sergey Alexandrovich Kryukov 8,906
1 OriginalGriff 7,771
2 CPallini 2,603
3 Richard MacCutchan 2,121
4 Abhinav S 1,928


Advertise | Privacy | Mobile
Web04 | 2.8.140827.1 | Last Updated 17 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100