Hi Aussie,
I hope you are well. There are two ways of doing it.
1. Use methods offered by ClientScriptMan ager class
i.e.
protected void Page_Load(objec t sender, EventArgs e)
{
// these variables should be set to values
// retreived from database
double x = 47.6;
double y = -122.33;
if (!ClientScript. IsClientScriptB lockRegistered( this.GetType(), "mapScript" ))
{
string script =
"<script type=\"text/javascript\">\n " +
"function GetMap() {{\n" +
" var map = new VEMap('myMap'); \n" +
" map.LoadMap(new VELatLong({0}, {1}), 10 ,'h' ,false);\n" +
"}}\n" +
"</script>";
ClientScript.Re gisterClientScr iptBlock(
this.GetType(),
"mapScript" ,
String.Format(s cript, x, y));
}
}
or storing retreived values in properties and then using <%%code block on
the aspx page:
-- code behind/beside --
protected void Page_Load(objec t sender, EventArgs e)
{
if (!IsPostBack)
{
// populate with values from database
XCoordinate = 47.6;
YCoordinate = -122.33;
}
}
// i used viewstate in order to
// not to make database roundtrips on postbacks
protected double XCoordinate
{
get
{
object value = ViewState["XCoordinat e"];
return value == null ? 0.0d : (double)value;
}
set
{
ViewState["XCoordinat e"] = value;
}
}
protected double YCoordinate
{
get
{
object value = ViewState["YCoordinat e"];
return value == null ? 0.0d : (double)value;
}
set
{
ViewState["YCoordinat e"] = value;
}
}
-- end code behind/beside --
-- aspx page code --
<script type="text/javascript">
function GetMap()
{
map = new VEMap('myMap');
map.LoadMap(new VELatLong(<%= XCoordinate %>, <%= YCoordinate %>), 10 ,'h'
,false);
}
</script>
-- end aspx page code --
Hope it helps
--
Milosz
"Aussie Rules" wrote:
Hi.
I am using Live Earth SDK, and have very little Javascript knowledge, but I
need to insert values into a Javascript function, where the vales are in the
ASP.net VB code.
The javascript function is below, but I need to replace the value
(47.6, -122.33) with variables in the code behind page that I get from my
SQL 2000 database.
Is there a way to do this ?
Thanks
function GetMap()
{
map = new VEMap('myMap');
map.LoadMap(new VELatLong(47.6, -122.33), 10 ,'h' ,false);
}