Avatar of MikeCombe
MikeCombeFlag 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
ASKER CERTIFIED SOLUTION
Avatar of Ajay Sharma
Ajay Sharma
Flag of India image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
SOLUTION
Avatar of pkbugudai
pkbugudai
Flag of India image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
SOLUTION
Avatar of darjimaulik
darjimaulik
Flag of India image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of MikeCombe
MikeCombe
Flag of United States of America image

ASKER

Thank you !!
.NET Programming
.NET Programming

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

137K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo