How to pass in value to javascript from database or let javascript to get value from database?

I am trying to use google map api to do some web based application.

On the map, the javascript needs latitude and longitude from database to draw a marker on page load, I am wondering how can I get the data from database to do that? The map part will be like a image, won't change.

Do I need Ajax?

Thank you.
 

0
hanxiao
7/9/2007 5:04:58 AM
asp.net.client-side 24353 articles. 1 followers. Follow

1 Replies
987 Views

Similar Articles

[PageSpeed] 39

hanxiao:

I am trying to use google map api to do some web based application.

On the map, the javascript needs latitude and longitude from database to draw a marker on page load, I am wondering how can I get the data from database to do that? The map part will be like a image, won't change.

You can write the values from a database straight into the javascript.  One way is to put Literal controls where the values go, and assign the values from the code-behind.

ASPX:

<script type="javascript">

function myFunc(){
var lat = <asp:Literal ID="Lat" runat="server" />;
var long = <asp:Literal ID="Long" runat="server" />;
...
</script>

Code behind:

Lat.Text = value from database
Long.Text = value from database

hanxiao:

Do I need Ajax?

 

No. 


Regards Mike
[MVP - ASP/ASP.NET]
My site
0
Mikesdotnetting
7/9/2007 7:14:35 AM
Reply:

Similar Artilces:

Getting Database Values Through Javascript
 Hi there,I am creating a web application using Dynamic Data and need some advice on my next step. I have a table in my database that stores longitude and latitude co-ordinates. I need to use Google Maps to get the lang/lat from the user. Once I have the lang/lat in Javascript how can I insert them into my Database? I am thinking along the lines of getting the input in javascript and then storing them in an array in the code behind. Hower how do I then programmaticaly insert them into the database. Any help would be greatly appreciated. Steve I think you should have a look at Mi...

javascript (id) and passing value from vb.net to javascript function
using vb.net 2005 I am modifying existing (wrote by someone else) code. There is a javascript function in my program: <CODE> function SomeTimePicker_OnFocus(id) { .... </CODE> but when the attribute is set to refer to this function there is no reference to (id) <CODE> someControl.AddAttribute("OnFocus", "SomeTimePicker_OnFocus();") </CODE> I mention this because I need to create a new version of this javascript functionand I need the (id) to remain there but I also want to pass in an integer valueto the javascript function. Questions: 1...

Selected value in select list with javascript based off value in database
 I've got a classic asp page with a select list. I need the select list's selected value to be whatever the user selected when they created their account. I've been trying to use <body onLoad="onLoad();"> to call my function, and then I'm trying to specify which value should be selected in the function. Also, when the select list selected values change, there is a javascript function I call to disable text boxes. I think there is an issue with my javascript function, and I can't find any examples of this from good ole' google.  My j...

how to pass retrived database value to javascript function?
hi,guys i m getting images from database into datalist. and i want to pass that retrived image id to javascript function and that is work on that id. that is 1.. document.getElementById('id') how to set my retrived id in above statement? thanks in advance.  Hello Sheetal,Don't know whether this help you or not.I have done this in a grid like     <img id="b<%#Eval("ID")%>" src="<%#Eval("ShapeImage")%>" onmousedown="dragStart(event,this.id,this.x,this.y)"      &...

to change value of Client Side Select html control from database value....
hello forum,  I have a select .. Demo.aspx <select id="DropAccType" name="DropAccType"> <option>Select</option> <option>Saving</option> <option >Current</option> <option>Regular</option> <option>Demat</option> </select> I want to set the value of select by fetching the data from daabase i.e. In my table if I have Value current then when i request the demo.aspx then in select Control the value Current should get selected..... Please help me to sort this out...   Thnx in advance.. Hi-I could be...

Passing values between client and server side (Javascript to C#)
I would like to access client side values from the code behind.Say I open a window like this popWindow = window.open("data_list.aspx", "dataWindow", 'toolbar,width=150,height=100')  How can I get the window name "dataWindow" from that current window or the parent window? Any other examples accessing variables between server side (C#) and client side (JavaScript) would be greatly appreciated. Regards -WH   Page.Request.ServerVariables["SCRIPT_NAME"] will get the name of the current page.  You can also pass values in a querystring, which will make them access...

Get the Dropdownlist text and value using Javascript from client side
Hi, I am encountering a problem about how to get the Dropdownlist text and value using Javascript from client side. I am using C# in Visual Studio 2005 and Javasript . The example codes are like: ( In this example code, I would like to access the text and value of the DropDownListReports in the run() function of Javascript. How can I do that? Any ideas? Thanks a lot. ) protected void Page_Load(object sender, EventArgs e) {              if (!Page.IsPostBack)            &nb...

In datawindow.net,access the database from client side event using javascript
In powerbuilder,for example,a datawindow has two columns:itemno,description. input an itemno,validate it.if not found from the database,return 1 to trigger itemerror event; if found,get the description of the item from the database,and fill it into the column "description". The question is how to fulfill the function in web datawindow,through web service? if so,I need an example to realize it. You will need to use AJAX or make a round trip on item change event. -- Dean Jones CEO PowerObjects http://www.powerobjects.com (612) 339-3355 Ext. 112 TeamSybase * *...

passing values form values to javascripts as arguements
How to pass text-box values etc (ASP.NET Form elements' values) as arguments to  javascript functions? Pls Help..  javascriptFunctionCall(document.getElementById('< Form element's ClientID >').value); more specificallydocument.getelementbyid('<%=controlID.clientID%>') ------------------------------------------------Jeff Turner (simpleModus)Don't forget to mark the correct answer for yourquestion to help out future visitors! just one question, wat's 'clientID' here? clientid is what the id will appear as when the html is rendered. What's rendered in the ...

insert javascript values into database
    Greetings I have a vb.net page - it is an iframe - and it gathers values from its parent page using javascript, ie, parent.document.myForm.email.value, etc. I would like to know how in vb.net do I get these values so that they can be added to a database? thanks for your help. Assuming .NET 1.1 you gather those into variables then post them to the server with a client-side action.  Simple method is a form with hidden fields and a submit, then process the request and data server-side to populate the database.JeffPlease: Don't forget to click "Ma...

Problem accessing server side array values from client side javascript function
i faced the following problem ..i have an array that store the values of a resultset row under the server side coding.How do i retrieve them under my client side javascript function.I wrote the following coding under my client side function and it got an error.BSCStr is an array storing data from a resultset row which i did under the server side coding. From client side function: addr=addr + "&C" + i + "=" + <%=BSCStr[i]%>;...

Problem accessing server side array values from javascript client side function
i faced the following problem ..i have an array that store the values of a resultset row under the server side coding.How do i retrieve them under my client side javascript function.I wrote the following coding under my client side function and it got an error.BSCStr is an array storing data from a resultset row which i did under the server side coding. From client side function: addr=addr + "&C" + i + "=" + <%=BSCStr[i]%>; First of all, you can't mix server-side and client-side code. The reason is that the protocol that is used to communicate betwee...

Getting value from a textbox control that was filled with a value from javascript
 I have a textbox control (seen below txtMileageDollars1) that gets filled with javascript based on the number of miles a user types into another textbox (txtMileageMiles1) control.  When I post back with the submit button, the value is blank.  I've tried setting EnableViewState to false, but still cannot get a value on postback.  Does anyone have a solution?   Miles<asp:TextBox ID="txtMileageMiles1" runat="server" Width="50px"></asp:TextBox>   Total (txtMileageMiles1 * rate with javascript)<asp:TextBox...

Passing JavaScript value to Server Side
Hi all, Is there anyway i can get a value from a client side textarea and use the value in server side processing? Unfortunately, Request.Form["var"] isnt an option for me to use. You most certainly can.  --aspx page--<asp:TextBox runat="server" id="textbox1"/>--server-side code--Response.write("The value of textbox1 is " & textbox1.Text) 'This is VB.NET CodeResponse.write("The value of textbox1 is " + textbox1.Text); //This is C# CodeIf your server-side code is in a code-behind file then you need to add this at the top of the class:--aspx.vb--Protected textbox1 as TextBox-...