473,769 Members | 7,097 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Mixing javascript and ASP.net code

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);
}

Jun 14 '07 #1
3 1694
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);
}

Jun 14 '07 #2
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.

--
Göran Andersson
_____
http://www.guffa.com
Jun 14 '07 #3
function GetMap()
{
map = new VEMap('myMap');
map.LoadMap(new VELatLong(<%=co debehindfunc1() %>,
<%=codebehindfu nc2()%>),
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);
}
Jun 15 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5076
by: cheezebeetle | last post by:
ok, so I am having problems passing in an ASPX function into the Javascript in the codebehind page. I am simply using a confirm call which when they press "OK" they call this ASPX function, when they press "Cancel" they call another ASPX function. My code now is: System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE=""JavaScript"">" & vbCrLf) System.Web.HttpContext.Current.Response.Write("if (confirm('Are you sure you want to...
1
1099
by: Lloyd Sheen | last post by:
I am having big time problems seperating the two mention in subject line. I want to create a list of items (listbox or select) from a button click (on the server). The button click will ensure that all data required for viewing the page is within the page and after that selecting items from the table should cause client processing to modify the look of the page. The server code is easy. I access data on the server and add it to the...
1
325
by: Mario Rodriguez | last post by:
HI People, I need to mix ASP.NET (using C#) and vbscript (to handle capicom resources) but I'm getting a lot of javascript errors. There is a safe way to mix vbscript and ASP.NET thanks
5
1526
by: Shawn Repphan | last post by:
I have a webform with about 20 html textboxes and checkboxes. I am using ICallbackEventHandler to page through these successfully. But I need to be able to accept changes from these fields. How can I access an html field from ASP.net? Or better yet, how do I access server controls from javascript? The latter would be possible if ASP.net always gives the textboxes the excat same ID.
7
2670
by: Ubantu Rococo | last post by:
Hi all, Sorry for this stupid question, but I am having trouble mixing imagecopy etc. with HTML. What I am trying to do is copy an image, and then obtain co-ordinates from a database which will then be drawn on the image (to create a clickable imagemap). The image will then be displayed as part of a webpage. I've included my code snippet below. It doesn't work, and I think I know why - the output on my screen
28
3095
by: ziman137 | last post by:
Hello all, I have a question and am seeking for some advice. I am currently working to implement an algorithmic library. Because the performance is the most important factor in later applications, I decide to write it in C instead of C++. However, I thought it might be convenient to use some C++ code at some misc places. I'm aware that, I could always use the C++ compiler to get it work.
7
1540
by: =?Utf-8?B?am9uZWZlcg==?= | last post by:
I'm hoping this is a classic question, but the answer to it would help me with a lot of things. As you can see below, this code will never display the "Getting data...." text in the lblCheck - because it needs to do a round-trip to the server - first. And when it gets back, my other routine will over-write the text as "34 records found" Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles...
1
2216
by: basm101 | last post by:
Hello, Firstly, apologies if this should be in the javascript forum - I wasnt sure which was most appropriate to post this question in... I am not sure if my problem is caused by the way I am mixing java and javascript in my jsp and if it can be fixed. If currentObservation.getComment() (java) is not null then all is well. But if it is null, instead of just setting document.commentForm.commentBox.value to a blank string I get a...
2
1775
by: groupie | last post by:
Hi, This code is in <head>. If I write this: <script language="JavaScript" type="text/javascript"> <% if (oRs.BOF && oRs.EOF ) %> alert("hello"); </script> ....then the BOF/EOF methods are valid but the IF statement is not.
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10048
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9996
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8872
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7410
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6674
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3963
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3563
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.