troubleshooting Question

Using variables in javascript

Avatar of MikeCombe
MikeCombeFlag for United States of America asked on
JavaScript.NET Programming
4 Comments3 Solutions433 ViewsLast Modified:
I am trying to set an array string programatically using
then inserting the array string into a javascript statement.

To me, the error message indicates that the javascript is run first by the server, and
then the webpage code. That seems backwards to me. I thought the server
ran my webpage code first, enabling me to set variables, which I can then
insert into javascript code.

What am I doing wrong ?

Here is the error I get:
Error message: Name 'jARY_AdsTop_Homepage_path99' is not declared.
Line 25:       var jARY_AdsTop_Homepage_path = [<%=jARY_AdsTop_Homepage_path99%>];

Here is the webpage code:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="test_ad_rotation.aspx.vb" Inherits="wikiVB.test_ad_rotation" %>

Dim jARY_AdsTop_Homepage_path99 As String = "folder1/,folder2/"
Dim jARY_AdsTop_Homepage_url99 As String = ","

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">

<script type="text/javascript">
      var jARY_AdsTop_Homepage_path = [<%=jARY_AdsTop_Homepage_path99%>];
      var jARY_AdsTop_Homepage_url = [<%=jARY_AdsTop_Homepage_url99%>];
      //alert("jARY_AdsTop_Homepage_path = " + jARY_AdsTop_Homepage_path);
      //alert("jARY_AdsTop_Homepage_url = " + jARY_AdsTop_Homepage_url);
Ajay Sharma

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 3 Answers and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros