server side javascript array

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jvcoach23

    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.Str ingBuilder
    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>")
    RegisterStartup Script("Registe rClientScriptBl ock", mScript.ToStrin g())

    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
  • Eliyahu Goldin

    #2
    Re: server side javascript array

    Why don't you use the RegisterArrayDe claration method?

    --
    Eliyahu Goldin,
    Software Developer
    Microsoft MVP [ASP.NET]




    "jvcoach23" <shannonr@sucss .state.il.uswro te in message
    news:1383ly3ijx 2rg$.s770m2o8r3 kg$.dlg@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.Str ingBuilder
    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>")
    RegisterStartup Script("Registe rClientScriptBl ock", mScript.ToStrin g())
    >
    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

    Comment

    • jvcoach23

      #3
      Re: server side javascript array

      Thanks
      in doing a little searching... i see this

      RegisterArrayDe claration("Text Boxes","TextBox 1")
      RegisterArrayDe claration("Text Boxes", "TextBox2")

      and they say that it will produce

      <script language="javas cript" >
      <!--
      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


      Comment

      • jvcoach23

        #4
        Re: server side javascript array

        I added the ClientScript.Re gisterArrayDecl aration("mIconA ry",
        "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

        Comment

        • =?Utf-8?B?YnJ1Y2UgYmFya2Vy?=

          #5
          Re: server side javascript array

          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.Re gisterArrayDecl aration("mIconA ry",
          "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
          >

          Comment

          • jvcoach23

            #6
            Re: server side javascript array

            Found the problem... the line needed to read

            ClientScript.Re gisterArrayDecl aration("mIconA ry",
            "'http://maps.google.com/mapfiles/ms/icons/purple-pushpin.png'")


            I needed the single ' inside of the double "

            thanks
            shannon

            Comment

            Working...