Click here to Skip to main content
11,478,174 members (73,914 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: Javascript

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,
        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);
    //document.getElementById('messageDisplay').style.visibility = "hidden";

//Function handle the click event
function route() {


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") {
But it give error as ,
Microsoft JScript runtime error: Object expected.

what is wrong in code?..
Posted 16-Oct-12 21:18pm
Edited 16-Oct-12 21:22pm
(no name)69.7K
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 Sergey Alexandrovich Kryukov 184
1 OriginalGriff 160
2 Frankie-C 160
3 Sascha Lefèvre 145
4 F-ES Sitecore 120
0 Sergey Alexandrovich Kryukov 7,675
1 OriginalGriff 7,256
2 Sascha Lefèvre 3,034
3 Maciej Los 2,491
4 Richard Deeming 2,305

Advertise | Privacy | Mobile
Web04 | 2.8.150520.1 | Last Updated 17 Oct 2012
Copyright © CodeProject, 1999-2015
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