I'm building an ASP.NET AJAX Enabled application that Implements the Virtual Earth Control. For several reasons, I rely heavily on JavaScript, and am having issues seeing any of my functions when I add an asp control which calls to them. Here's the error:
Compiler Error Message: CS1061: 'ASP.default_aspx' does not contain a definition for 'LoadMapControl' and no extension method 'LoadMapControl' accepting a first argument of type 'ASP.default_aspx' could be found (are you missing a using directive or an assembly reference?)
I am not missing any assemblies that I know of:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MultiLanguageDirections.MWS;
And I am inheriting System.Web.UI.Page in my default class.
namespace MultiLanguageDirections
{
public partial class _Default : System.Web.UI.Page
Interestingly enough, if I do not add any controls with event calls to my .js, the script manager will load the map just fine, so I know the file (core.js) is loaded, but as soon as I add the DropDownList and add the event to any function, it blows up.
Default.aspx page:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="MultiLanguageDirections._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Multiple Language Directions</title>
<style type="text/css">
#Select1
{
width: 184px;
}
</style>
</head>
<body onload="LoadMap();">
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" >
<Scripts>
<asp:ScriptReference Path="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.1" />
<asp:ScriptReference Path="./core.js"/>
</Scripts>
</asp:ScriptManager>
<div id="banner" style="border-left: thin dashed blue; border-right: thin dashed blue; border-top: thin dashed blue; background-color:#CCCCFF; border-bottom: 0px; font-family: Helvetica, sans-serif; font-style: italic; font-size: medium; width: 521px">
</div>
<div id="myMap" style="position:relative; width:521px; height:250px;border:thin blue groove"></div>
<div>
<asp:DropDownList ID="DropDownList1" runat="server" OnTextChanged="LoadMapControl()"> (Problem child!)
<asp:ListItem Selected="True">English</asp:ListItem>
<asp:ListItem>Spanish</asp:ListItem>
</asp:DropDownList>
</div>
</form>
<p>
</p>
</body>
</html>
core.js:
/// <reference path="VeJavaScriptIntellisenseHelper.js" />
var myMap = null;
var ex;
function LoadMap()
{
try{
myMap=new VEMap('myMap');
myMap.SetClientToken(token);
myMap.LoadMap();
ex = VEException;
document.getElementById('banner').innerHTML = document.title;
}
catch(ex)
{
handleE(ex, "main");
}
function LoadMapControl(el)
{
var Language = document.getElementById('Select1').value;
var script = document.createElement("script");
if(Language =="Spanish")
{
alert("Spanish");
script.setAttribute("src", "http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6&mkt=es-ES");
}
script.setAttribute("type", "text/javascript");
document.documentElement.firstChild.appendChild(script);
GetMap();
}
function handleE(ex, from)
{
alert("Error : "+ex.message+" | occured From Source : "+ex.source+" | By the name of : "+ex.name+" | From Method : "+from);
}
}
So, do I need to do something different to call js functions from ASP.NET controls?