473,395 Members | 1,443 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

server side javascript array

I am trying to load an array on the load of a page to javascript. the
script will eventually have parts being loaded from a database... this is
just a first step to get there... Here is the code

Dim mScript As New System.Text.StringBuilder
mScript = mScript.Append("<script type='text/javascript'>" & vbNewLine)

mScript.Append("var mIconAry = new Array();" & vbNewLine)
mScript.Append("mIconAry[" & 0 & "]='" &
"http://maps.google.com/mapfiles/ms/icons/purple-pushpin.png" & "';" &
vbNewLine)
mScript.Append("mIconAry[" & 1 & "]='" &
"http://maps.google.com/mapfiles/ms/icons/green-pushpin.png" & "';" &
vbNewLine)

'mScript.Append("var mInfoBox = new Array();" & vbNewLine)
'mscript.Append("mInfoBox[" & 0 & "]='" &

mScript.Append("</script>")
RegisterStartupScript("RegisterClientScriptBlock", mScript.ToString())

when i run this.. the javascript isn't there. I've tried looking using
firefox and a plugin that allows you to see all the javascript and it's not
there.. i'm using the same technique as i've used on another page and it
works there.. i don't think i've left anything out.

I'd like to use this array to put pushpins onto a microsoft virutal earth
map that i'm using. anyway.. anyone have any idea's what i'm doing wrong
in my code above.

thanks
shannon
Feb 28 '08 #1
5 1850
Why don't you use the RegisterArrayDeclaration method?

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"jvcoach23" <sh******@sucss.state.il.uswrote in message
news:13******************************@40tude.net.. .
>I am trying to load an array on the load of a page to javascript. the
script will eventually have parts being loaded from a database... this is
just a first step to get there... Here is the code

Dim mScript As New System.Text.StringBuilder
mScript = mScript.Append("<script type='text/javascript'>" & vbNewLine)

mScript.Append("var mIconAry = new Array();" & vbNewLine)
mScript.Append("mIconAry[" & 0 & "]='" &
"http://maps.google.com/mapfiles/ms/icons/purple-pushpin.png" & "';" &
vbNewLine)
mScript.Append("mIconAry[" & 1 & "]='" &
"http://maps.google.com/mapfiles/ms/icons/green-pushpin.png" & "';" &
vbNewLine)

'mScript.Append("var mInfoBox = new Array();" & vbNewLine)
'mscript.Append("mInfoBox[" & 0 & "]='" &

mScript.Append("</script>")
RegisterStartupScript("RegisterClientScriptBlock", mScript.ToString())

when i run this.. the javascript isn't there. I've tried looking using
firefox and a plugin that allows you to see all the javascript and it's
not
there.. i'm using the same technique as i've used on another page and it
works there.. i don't think i've left anything out.

I'd like to use this array to put pushpins onto a microsoft virutal earth
map that i'm using. anyway.. anyone have any idea's what i'm doing wrong
in my code above.

thanks
shannon

Feb 28 '08 #2
Thanks
in doing a little searching... i see this

RegisterArrayDeclaration("TextBoxes","TextBox1")
RegisterArrayDeclaration("TextBoxes", "TextBox2")

and they say that it will produce

<script language="javascript" >
<!--
var TextBoxes = new Array(TextBox1, TextBox2);
// -->
</script>

is it as simple as that to get the array in there... i've tried it.. the
array is not showing up in the javascript.. so i'm just curious if what
i've read is incorrect.
thanks
Feb 28 '08 #3
I added the ClientScript.RegisterArrayDeclaration("mIconAry",
"http://maps.google.com/mapfiles/ms/icons/purple-pushpin.png")

to another page.. and when the page renders.. it puts the array in
var mIconAry = new
Array(http://maps.google.com/mapfiles/ms/i...-pushpin.png);

but when i try it on a different page, within the same project... on the
page with the microsoft map... it doesn't show up...

hope that is helpful
shannon
Feb 28 '08 #4
the non-woprking page probably does a redirect, so none of its html is of any
use.

-- bruce (sqlwork.com)
"jvcoach23" wrote:
I added the ClientScript.RegisterArrayDeclaration("mIconAry",
"http://maps.google.com/mapfiles/ms/icons/purple-pushpin.png")

to another page.. and when the page renders.. it puts the array in
var mIconAry = new
Array(http://maps.google.com/mapfiles/ms/i...-pushpin.png);

but when i try it on a different page, within the same project... on the
page with the microsoft map... it doesn't show up...

hope that is helpful
shannon
Feb 28 '08 #5
Found the problem... the line needed to read

ClientScript.RegisterArrayDeclaration("mIconAry",
"'http://maps.google.com/mapfiles/ms/icons/purple-pushpin.png'")
I needed the single ' inside of the double "

thanks
shannon
Feb 28 '08 #6

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

Similar topics

9
by: Kathryn | last post by:
Hiya I have a problem with using some client side and server side scripting together in an ASP. I'm using VBScript. What I'm trying to achieve is this - - Page loads up and some server side...
3
by: Mick Turner | last post by:
I have connected to SQL Server database (server-side vbscript) and read some data from the tables. This works correctly. I now have the data in an array (server-side). I have to draw a...
1
by: John | last post by:
Hi, we have the following problem: in our application v1.0 we have static html pages (+ some javascript). With a CMS (a Content Management System) some "mortal" people can add or expand the...
26
by: Don | last post by:
I'm writing an html page with some JavaScript that reads a web page into a client-side temp file, then reformats it, then submits that same file as a URL to the browser for display, via...
5
by: Casey | last post by:
Hello, Can someone give me specific code to replace text on a page using server side javascript? I need to use server-side because I need the output to be recognized in the final HTML so that...
10
by: Lyners | last post by:
Hello all, I have an ASP.NET website where one of my pages contain javascript that is a check to see if anydata within a datagrid has changed. My problem is that it takes a considerable amount of...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
7
by: Tony Girgenti | last post by:
Hello. I'm trying to undetrstand ASP.NET 2.0 and javascript. When i have a button and i click on it and i see the web broswer progress bar at the bottom do something, does that mean that there...
3
by: balurajeev | last post by:
Hii, currently i am working on an apliction(ASP.NET/C#) that creates dynamic html rows which contain six html text boxes and a html dropdowllist. At the time of page load the web page contain six...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.