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);
}Hi Aussie,
I hope you are well. There are two ways of doing it.
1. Use methods offered by ClientScriptManager class
i.e.
protected void Page_Load(object sender, EventArgs e)
{
// these variables should be set to values
// retreived from database
double x = 47.6;
double y = -122.33;
if (!ClientScript.IsClientScriptBlockRegistered(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.RegisterClientScriptBlock(
this.GetType(),
"mapScript",
String.Format(script, x, y));
}
}
or storing retreived values in properties and then using <%%> code block on
the aspx page:
-- code behind/beside --
protected void Page_Load(object 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["XCoordinate"];
return value == null ? 0.0d : (double)value;
}
set
{
ViewState["XCoordinate"] = value;
}
}
protected double YCoordinate
{
get
{
object value = ViewState["YCoordinate"];
return value == null ? 0.0d : (double)value;
}
set
{
ViewState["YCoordinate"] = 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 t
he
> 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);
> }
>
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);
> }
>
Put a Literal control where you want the value, and set the Text
property of the control in code behind.
Gran Andersson
_____
http://www.guffa.com
function GetMap()
{
map = new VEMap('myMap');
map.LoadMap(new VELatLong(<%=codebehindfunc1()%>,
<%=codebehindfunc2()%> ),
10 ,'h' ,false);
}
-- bruce (sqlwork.com)
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);
> }
>
0 comments:
Post a Comment