Click here to Skip to main content
15,892,797 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a button control as

ASP.NET
<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,

HTML
<script language="javascript" type="text/javascript" src="../Script/Map.js"></script>


Map.js content as below,

----------------------------------

JavaScript
//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

--------------------------

HTML
<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
Updated 16-Oct-12 20:22pm
v3
Comments
Arunprasath Natarajan 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900