R
ruca
Hi,
How can I pass an array string to javascript?
I have this:
in ASP.NET VB code:
--------------------------------------------------------------------
Dim siteName(100) As String
Dim siteLink(100) As String
Dim i As Integer
siteName(0) = "New JavaScripts"
siteName(1) = "Item 2"
siteName(2) = "Item 3"
siteName(3) = "Item 4"
siteName(4) = "Item 5"
siteName(5) = "Item 6"
siteLink(0) = "link1"
siteLink(1) = "link2"
siteLink(2) = "link3"
siteLink(3) = "link4"
siteLink(4) = "link5"
siteLink(5) = "link6"
Dim sbScript As New System.Text.StringBuilder
sbScript.Append("<script language='javascript'>")
sbScript.Append(Environment.NewLine)
sbScript.Append("createMenu('siteName','siteLink');")
sbScript.Append(Environment.NewLine)
sbScript.Append("</script>")
RegisterStartupScript("OpenMenu", sbScript.ToString())
--------------------------------------------------------------------
in HTML code I have this (at javascript, of course):
function createMenu(siteName, siteLink)
{
for (i = 0; i <= siteName.length - 1; i++)
document.write('<a href=' + siteLink + '>' + siteName + '</a><br>');
}
How can I pass an array string to javascript?
I have this:
in ASP.NET VB code:
--------------------------------------------------------------------
Dim siteName(100) As String
Dim siteLink(100) As String
Dim i As Integer
siteName(0) = "New JavaScripts"
siteName(1) = "Item 2"
siteName(2) = "Item 3"
siteName(3) = "Item 4"
siteName(4) = "Item 5"
siteName(5) = "Item 6"
siteLink(0) = "link1"
siteLink(1) = "link2"
siteLink(2) = "link3"
siteLink(3) = "link4"
siteLink(4) = "link5"
siteLink(5) = "link6"
Dim sbScript As New System.Text.StringBuilder
sbScript.Append("<script language='javascript'>")
sbScript.Append(Environment.NewLine)
sbScript.Append("createMenu('siteName','siteLink');")
sbScript.Append(Environment.NewLine)
sbScript.Append("</script>")
RegisterStartupScript("OpenMenu", sbScript.ToString())
--------------------------------------------------------------------
in HTML code I have this (at javascript, of course):
function createMenu(siteName, siteLink)
{
for (i = 0; i <= siteName.length - 1; i++)
document.write('<a href=' + siteLink + '>' + siteName + '</a><br>');
}