MikeCombe
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_path 99' is not declared.
Line 25: var jARY_AdsTop_Homepage_path = [<%=jARY_AdsTop_Homepage_p ath99%>];
Here is the webpage code:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="test_ad_rotati on.aspx.vb " Inherits="wikiVB.test_ad_r otation" %>
<%
Dim jARY_AdsTop_Homepage_path9 9 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_p ath99%>];
var jARY_AdsTop_Homepage_url = [<%=jARY_AdsTop_Homepage_u rl99%>];
//alert("jARY_AdsTop_Homep age_path = " + jARY_AdsTop_Homepage_path) ;
//alert("jARY_AdsTop_Homep age_url = " + jARY_AdsTop_Homepage_url);
</script>
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_path
Line 25: var jARY_AdsTop_Homepage_path = [<%=jARY_AdsTop_Homepage_p
Here is the webpage code:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="test_ad_rotati
<%
Dim jARY_AdsTop_Homepage_path9
Dim jARY_AdsTop_Homepage_url99
%>
<!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_p
var jARY_AdsTop_Homepage_url = [<%=jARY_AdsTop_Homepage_u
//alert("jARY_AdsTop_Homep
//alert("jARY_AdsTop_Homep
</script>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER