Avatar of MikeCombe
MikeCombe
Flag for United States of America asked on

Using asp.net variables in javascript

I am trying to set an array string programatically using asp.net
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 asp.net webpage code. That seems backwards to me. I thought the server
ran my asp.net 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 = "http://www.google.com,http://www.google.com"
%>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>


<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);
</script>
.NET ProgrammingJavaScript

Avatar of undefined
Last Comment
MikeCombe

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Ajay Sharma

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
pkbugudai

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
MikeCombe

ASKER
Thank you !!
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes