Solved

Can you pass an array in Visual basic to javascript?

Posted on 2008-10-28
20
350 Views
Last Modified: 2013-11-25
I have some code in visual basic, the main sub displays the parsed file contents, and createds an output that displays them as a list - can I alter this to pass it into a javscript array?


 Sub Main()
        Dim arr As New ArrayList
        arr = parseFile(Server.MapPath("Messageboard.html"))
        Dim a As Array = arr.ToArray  (HERE IS WHERE I THINK I CAN MAKE THIS PASS TO A JAVASCRIPT ARRAY>>>>)
        Dim sOutput As String = ""
        For i As Long = 0 To a.Length - 1
            sOutput = sOutput + a(i) + "<BR><BR><BR><BR><BR><BR>"  (HERE IS WHERE THE PARSED CONTENT IS ADDED)
            myLiteralControl.Text = sOutput (COULD JUST AS WELL BE RESPONSE WRITE ALSO< DISPLAYS THE HTML ON A PAGE)

        Next

    End Sub
0
Comment
Question by:theclassic
  • 9
  • 8
  • 3
20 Comments
 
LVL 16

Expert Comment

by:sh0e
ID: 22825154
Sub printArray(intArray() As Integer)

Dim obj As Variant

For Each obj In intArray

Response.Write obj

Next

End Sub
0
 

Author Comment

by:theclassic
ID: 22825541
can you post with the namings used in my existing SUB, and then tell me how it would be passed to the javascript, say, this example (which as it is shown is using a data set and control to pass to the array - but i want to replace it with the example above)...?  Sorry I am somewhat of a begginner,,,
 

var currentMessageIndex = 0
var ns4 = (document.layers)? true:false;
var msie = (document.all)? true:false;
THIS VB SCRIPT WOULD BE REPLACED BY PASSING THE ARRAY YOU HAVE NAMED somehow....
var messages = new Array(<%= dsMessages.tables(0).rows().count %>);
<%
 dim intMessageCount as integer = 0
 dim drMessage as datarow
 for each drMessage in dsMessages.tables(0).rows
  response.write ("messages[" & intMessageCount & "] = """ & server.htmlDecode(server.htmlEncode(drMessage("Message"))) & """;" & vbcrlf)
  intMessageCount += 1
 next
%>
function startMessageBoard(){
 document.getElementById("innerDiv").innerHTML = messages[currentMessageIndex];
 window.setTimeout("moveMessagesUp()", 0);
}
0
 
LVL 16

Expert Comment

by:sh0e
ID: 22826268
What ASP is sending to the browser is text, not objects.  The VBScript ASP code executes on the server-side, and the JavaScript on the client side, so you cannot directly pass objects between them.  The objects must be serialized into text in between, this text being sent over HTTP.

server-side -> HTTP -> client side
ASP -> HTTP -> JavaScript

If you want to encapsulate the code, you can turn it into a function.

If you want to separate JavaScript from your server side code and data, you will have to separate the logic for pushing data, and the logic for JavaScript to grab data.  Something like a page that serializes data from the database into JSON (JavaScript Object Notation), which the JavaScript grabs using AJAX.  This will take a significant amount of learning and thinking, and would require a large amount of changes and time.

Example:
<%

Sub outputdatarow(dsMessages() as datarow)

dim intMessageCount as integer = 0

dim drMessage as datarow

for each drMessage in dsMessages.tables(0).rows

 response.write ("messages[" & intMessageCount & "] = """ & server.htmlDecode(server.htmlEncode(drMessage("Message"))) & """;" & vbcrlf)

 intMessageCount += 1

next

End Sub

%>
 

var currentMessageIndex = 0

var ns4 = (document.layers)? true:false;

var msie = (document.all)? true:false;
 

THIS VB SCRIPT WOULD BE REPLACED BY PASSING THE ARRAY YOU HAVE NAMED somehow....

var messages = new Array(<%= dsMessages.tables(0).rows().count %>);

<%

outputdatarow dsMessages

%>

function startMessageBoard(){

document.getElementById("innerDiv").innerHTML = messages[currentMessageIndex];

window.setTimeout("moveMessagesUp()", 0);

}

Open in new window

0
 
LVL 19

Expert Comment

by:NerdsOfTech
ID: 22827324
Have you tryed making your array dynamic so that you don't run into resize errors?
var currentMessageIndex = 0

var ns4 = (document.layers)? true:false;

var msie = (document.all)? true:false;

var messages = new Array(); // dynamic array

<%

dim intMessageCount as integer = 0

dim drMessage as datarow

for each drMessage in dsMessages.tables(0).rows

 response.write ("messages[" & intMessageCount & "] = """ & server.htmlDecode(server.htmlEncode(drMessage("Message"))) & """;" & vbcrlf)

 intMessageCount += 1

next

%>

function startMessageBoard(){

document.getElementById("innerDiv").innerHTML = messages[currentMessageIndex];

window.setTimeout("moveMessagesUp()", 0);

} 

Open in new window

0
 
LVL 19

Expert Comment

by:NerdsOfTech
ID: 22827326
var currentMessageIndex = 0;
var ns4 = (document.layers)? true:false;
var msie = (document.all)? true:false;
var messages = new Array(); // dynamic array
<%
dim intMessageCount as integer = 0
dim drMessage as datarow
for each drMessage in dsMessages.tables(0).rows
 response.write ("messages[" & intMessageCount & "] = """ & server.htmlDecode(server.htmlEncode(drMessage("Message"))) & """;" & vbcrlf)
 intMessageCount += 1
next
%>
function startMessageBoard(){
document.getElementById("innerDiv").innerHTML = messages[currentMessageIndex];
window.setTimeout("moveMessagesUp()", 0);
}
0
 
LVL 19

Expert Comment

by:NerdsOfTech
ID: 22827338

var currentMessageIndex = 0;

var ns4 = (document.layers)? true:false;

var msie = (document.all)? true:false;

var messages = new Array(); // dynamic array

<%

dim intMessageCount as integer = 0

dim drMessage as datarow

for each drMessage in dsMessages.tables(0).rows

 response.write (("messages[" & intMessageCount & "] = """ & server.htmlDecode(server.htmlEncode(drMessage("Message"))) & """;" & vbcrlf))

 intMessageCount += 1

next

%>

function startMessageBoard(){

document.getElementById("innerDiv").innerHTML = messages[currentMessageIndex];

window.setTimeout("moveMessagesUp()", 0);

} 

Open in new window

0
 

Author Comment

by:theclassic
ID: 22830918
Hold up - I think I am confusing everyone......I posted this code awhile back and got to a point, but no one could figure it out - who is up for the challenge?
To explain the previous posts....The VB SCRIPT was from an older application that used a data base to retrieve messages.
I want to use the javascript from this older application that scrolls and fades each message with my new code. The new code was written to parse an html file that is generated from a internal application, and adds comments to each line of html, which is why the parser(new code) is written as it is - here is that code...
 
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Main()
End Sub
'
' *-----
' ** Constants
' *-----
Dim BEGIN_PATTERN As String = "<!--Begin MessageBoard:Content"
Dim END_PATTERN As String = "<!--End MessageBoard:Content"
'
' *-----
' ** function extractText - returns the text between the start and end tags
' *-----
Private Function extractText(ByVal txt As String, ByVal target1 _
As String, ByVal target2 As String) As String
Dim startPos As Long
Dim endPos As Long
Dim content As String = ""
startPos = InStr(txt, target1)
endPos = InStr(txt, target2)
If startPos = 0 Or endPos = 0 Then
' start or end tag is missing. Set content = "".
content = ""
Else
startPos += target1.Length() + 4
content = Mid$(txt, startPos, (endPos - startPos))
End If
Return content
End Function
 
'
' *-----
' ** function parseFile - returns an ArrayList of content strings extracted
' ** from the file passed in as an argument
' *-----
Function parseFile(ByVal fileName As String) As ArrayList
Dim arrList As New ArrayList
If System.IO.File.Exists(fileName) = True Then
Dim objReader As New System.IO.StreamReader(fileName)
Dim txLine As String = ""
Do While objReader.Peek() <> -1
txLine = objReader.ReadLine()
If txLine.Contains(BEGIN_PATTERN) Then
Dim content As String = ""
content = extractText(txLine, BEGIN_PATTERN, END_PATTERN)
arrList.Add(content)
End If
Loop
objReader.Close()
Else
Response.Write("This messageboard is currently under construction.")
End If
Return arrList
End Function
 
Sub Main()
Dim arr As New ArrayList
arr = parseFile(Server.MapPath("Messageboard.html"))
Dim a As Array = arr.ToArray
Dim sOutput As String = ""
For i As Long = 0 To a.Length - 1
//This bottom section can simply be a repsonse.write instead of a control also.....

sOutput = sOutput + a(i) + "<BR><BR><BR><BR><BR><BR>"
myLiteralControl.Text = sOutput

Next
End Sub
End Class
//End of NEW CODE
 
Here is the older java and vb script from the older program (I want to pass the array listed here into a javascript array, i.e. replace the vb script pulling the array from a database, set up in a seperate vb file, but this would be all we were concerned with....

var currentMessageIndex = 0
var ns4 = (document.layers)? true:false;
var msie = (document.all)? true:false;
HERE IS WHERE I THINK I CAN PASS THE ARRAY SOMEHOW....
var messages = new Array(<%= dsMessages.tables(0).rows().count %>);
<%
 dim intMessageCount as integer = 0
 dim drMessage as datarow
 for each drMessage in dsMessages.tables(0).rows
  response.write ("messages[" & intMessageCount & "] = """ & server.htmlDecode(server.htmlEncode(drMessage("Message"))) & """;" & vbcrlf)
  intMessageCount += 1
 next
%>
function startMessageBoard(){
 document.getElementById("innerDiv").innerHTML = messages[currentMessageIndex];
 window.setTimeout("moveMessagesUp()", 0);
}
function moveMessagesUp(){
 if (ns4){
  document.layers["innerDiv"].visibility = "show";
 }
 
 if (msie){
  document.getElementById("innerDiv").style.visibility = 'visible';
 }
 
 if (document.getElementById("innerDiv").style.pixelTop != 10) {
  document.getElementById("innerDiv").style.pixelTop = document.getElementById("innerDiv").style.pixelTop - 1;
  window.setTimeout("moveMessagesUp()", 38);
 } else {
  hideCurrentMessageAndShowNext();  
 }
}
function hideCurrentMessageAndShowNext(){
 
 var timeToWait = 8000;
 
 window.setTimeout("hideMessages()", timeToWait/2);
 window.setTimeout("resetInnerDiv();", timeToWait);
 window.setTimeout("moveMessagesUp();", timeToWait);
}
function resetInnerDiv(){
 if (currentMessageIndex != messages.length - 1) {
  currentMessageIndex += 1;
 } else {
  currentMessageIndex = 0;
 }
 
 document.getElementById('innerDiv').innerHTML = messages[currentMessageIndex];
 document.getElementById('innerDiv').style.pixelTop = 50;
 
 if (ns4){
  document.layers["innerDiv"].visibility = "hide";
 }
 
 if (msie){
  document.getElementById('innerDiv').style.visibility='hidden';
 }
}
function hideMessages(){
 document.getElementById('innerDiv').style.width = '159px';
 document.getElementById('innerDiv').style.filter='blendTrans(duration=2)';
 document.getElementById('innerDiv').filters.blendTrans.apply();
 
 
 if (ns4){
  document.layers["innerDiv"].visibility = "hide";
 }
 
 if (msie){
  document.getElementById('innerDiv').style.visibility='hidden';
 }
 
 document.getElementById('innerDiv').filters.blendTrans.play();
}
 
Is everyone on the same page?
0
 

Author Comment

by:theclassic
ID: 22830949
To be clear, I want to pass the array from the top visual basic code into the bottom section to get the same display effects of the old program....Thank you!!!
0
 
LVL 16

Expert Comment

by:sh0e
ID: 22837759
The modified "NEW" code.  I changed the function to output JavaScript array code.
(messages=['val1','val2','val3','val4',...];)
This program may fail if you have any single quotes in the text.  If so a(i) will need to be encoded.
Partial Class _Default

Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Main()

End Sub

'

' *-----

' ** Constants

' *-----

Dim BEGIN_PATTERN As String = "<!--Begin MessageBoard:Content"

Dim END_PATTERN As String = "<!--End MessageBoard:Content"

'

' *-----

' ** function extractText - returns the text between the start and end tags

' *-----

Private Function extractText(ByVal txt As String, ByVal target1 _

As String, ByVal target2 As String) As String

Dim startPos As Long

Dim endPos As Long

Dim content As String = ""

startPos = InStr(txt, target1)

endPos = InStr(txt, target2)

If startPos = 0 Or endPos = 0 Then

' start or end tag is missing. Set content = "".

content = ""

Else

startPos += target1.Length() + 4

content = Mid$(txt, startPos, (endPos - startPos))

End If

Return content

End Function

 

'

' *-----

' ** function parseFile - returns an ArrayList of content strings extracted

' ** from the file passed in as an argument

' *-----

Function parseFile(ByVal fileName As String) As ArrayList

Dim arrList As New ArrayList

If System.IO.File.Exists(fileName) = True Then

Dim objReader As New System.IO.StreamReader(fileName)

Dim txLine As String = ""

Do While objReader.Peek() <> -1

txLine = objReader.ReadLine()

If txLine.Contains(BEGIN_PATTERN) Then

Dim content As String = ""

content = extractText(txLine, BEGIN_PATTERN, END_PATTERN)

arrList.Add(content)

End If

Loop

objReader.Close()

Else

Response.Write("This messageboard is currently under construction.")

End If

Return arrList

End Function

 

 'replaced Sub Main with code to generate JavaScript array code

Sub Main

Dim arr As New ArrayList

arr = parseFile(Server.MapPath("Messageboard.html"))

Dim a As Array = arr.ToArray

Dim sOutput As String = ""
 

sOutput = "messages=["
 

For i As Long = 0 To a.Length - 1

sOutput = sOutput + a(i) + ","

Next 
 

sOutput = sOutput + "];"

myLiteralControl.Text = sOutput

End Sub

End Class

Open in new window

0
 
LVL 16

Expert Comment

by:sh0e
ID: 22837770
JavaScript code.  I placed the Literal control in the code to set the messages array.
var currentMessageIndex = 0

var ns4 = (document.layers)? true:false;

var msie = (document.all)? true:false;
 

<asp:literal runat="server" id="myLiteralControl" ></asp:literal>
 

function startMessageBoard(){

document.getElementById("innerDiv").innerHTML = messages[currentMessageIndex];

window.setTimeout("moveMessagesUp()", 0);

}

function moveMessagesUp(){

if (ns4){

 document.layers["innerDiv"].visibility = "show";

}
 

 if (msie){

 document.getElementById("innerDiv").style.visibility = 'visible';

}
 

 if (document.getElementById("innerDiv").style.pixelTop != 10) {

 document.getElementById("innerDiv").style.pixelTop = document.getElementById("innerDiv").style.pixelTop - 1;

 window.setTimeout("moveMessagesUp()", 38);

} else {

 hideCurrentMessageAndShowNext();  

}

}

function hideCurrentMessageAndShowNext(){
 

 var timeToWait = 8000;
 

 window.setTimeout("hideMessages()", timeToWait/2);

 window.setTimeout("resetInnerDiv();", timeToWait);

window.setTimeout("moveMessagesUp();", timeToWait);

}

function resetInnerDiv(){

if (currentMessageIndex != messages.length - 1) {

 currentMessageIndex += 1;

} else {

 currentMessageIndex = 0;

}
 

 document.getElementById('innerDiv').innerHTML = messages[currentMessageIndex];

document.getElementById('innerDiv').style.pixelTop = 50;
 

 if (ns4){

 document.layers["innerDiv"].visibility = "hide";

}
 

 if (msie){

 document.getElementById('innerDiv').style.visibility='hidden';

}

}

function hideMessages(){

 document.getElementById('innerDiv').style.width = '159px';

document.getElementById('innerDiv').style.filter='blendTrans(duration=2)';

document.getElementById('innerDiv').filters.blendTrans.apply();
 

 

if (ns4){

 document.layers["innerDiv"].visibility = "hide";

}
 

 if (msie){

 document.getElementById('innerDiv').style.visibility='hidden';

}
 

 document.getElementById('innerDiv').filters.blendTrans.play();

}

Open in new window

0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 16

Expert Comment

by:sh0e
ID: 22837780
You will have to place the above code in the correct respective places in the .aspx and .aspx.vb files.

Below is my explanation of the issues and what I think you may not be understanding.  Also, why your question cannot be directly answered.
-----
Again, I think that you are misunderstanding that JavaScript is executed on the client-side, while the VBScript ASP code is executed on the server-side.  To the VBScript ASP engine, the JavaScript is nothing more than text to be sent to the client-side.
You cannot directly pass objects from the VBScript on the server-side to the JavaScript on the client-side.

The process from server to browser is as follows:
On the server, ASP VBScript executes some code and outputs text (that includes the JavaScript code).
Web Server sends this output text to the client's browser.
Client's browser parses text, sees JavaScript code and executes, and renders page.
0
 

Author Comment

by:theclassic
ID: 22840663
I understand the client/serverside execution - that is the main problem with this - I have written the code for another scrolling board, that is a continuos scroll, and places the asp:literal in a div, and then javascript is applied to the contents of a div.  Because each piece of content needs to be affected seperately, you have to spluit each message up for what I am trying to do here, and then apply javascript to each message.
 
I ran your code - it is giving me a runtime error - Line 12, it says "[" expected....
Here is the aspx page...

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!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>
<script language=javascript>
var currentMessageIndex = 0
var ns4 = (document.layers)? true:false;
var msie = (document.all)? true:false;

<asp:literal runat="server" id="myLiteralControl" ></asp:literal>

function startMessageBoard(){
document.getElementById("innerDiv").innerHTML = messages[currentMessageIndex];
window.setTimeout("moveMessagesUp()", 0);
}
function moveMessagesUp(){
if (ns4){
document.layers["innerDiv"].visibility = "show";
}

if (msie){
document.getElementById("innerDiv").style.visibility = 'visible';
}

if (document.getElementById("innerDiv").style.pixelTop != 10) {
document.getElementById("innerDiv").style.pixelTop = document.getElementById("innerDiv").style.pixelTop - 1;
window.setTimeout("moveMessagesUp()", 38);
} else {
hideCurrentMessageAndShowNext();
}
}
function hideCurrentMessageAndShowNext(){

var timeToWait = 8000;

window.setTimeout("hideMessages()", timeToWait/2);
window.setTimeout("resetInnerDiv();", timeToWait);
window.setTimeout("moveMessagesUp();", timeToWait);
}
function resetInnerDiv(){
if (currentMessageIndex != messages.length - 1) {
currentMessageIndex += 1;
} else {
currentMessageIndex = 0;
}

document.getElementById('innerDiv').innerHTML = messages[currentMessageIndex];
document.getElementById('innerDiv').style.pixelTop = 50;

if (ns4){
document.layers["innerDiv"].visibility = "hide";
}

if (msie){
document.getElementById('innerDiv').style.visibility='hidden';
}
}
function hideMessages(){
document.getElementById('innerDiv').style.width = '159px';
document.getElementById('innerDiv').style.filter='blendTrans(duration=2)';
document.getElementById('innerDiv').filters.blendTrans.apply();


if (ns4){
document.layers["innerDiv"].visibility = "hide";
}

if (msie){
document.getElementById('innerDiv').style.visibility='hidden';
}

document.getElementById('innerDiv').filters.blendTrans.play();
}
</script>
</head>
<body
<div id="outerDiv" name="outerDiv" style="position:relative; height:130px; width:159px; overflow:hidden;">
<div id="innerDiv" name="innerDiv" style="position:absolute; top:123px; left:0px; right:0px; visibility:visible;" class="body-nomarginprp">test</div>
</div>
</body>
</html>
 Here is the code behind...what am I missing?

Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Main()
End Sub
'
' *-----
' ** Constants
' *-----
Dim BEGIN_PATTERN As String = "<!--Begin MessageBoard:Content"
Dim END_PATTERN As String = "<!--End MessageBoard:Content"
'
' *-----
' ** function extractText - returns the text between the start and end tags
' *-----
Private Function extractText(ByVal txt As String, ByVal target1 _
As String, ByVal target2 As String) As String
Dim startPos As Long
Dim endPos As Long
Dim content As String = ""
startPos = InStr(txt, target1)
endPos = InStr(txt, target2)
If startPos = 0 Or endPos = 0 Then
' start or end tag is missing. Set content = "".
content = ""
Else
startPos += target1.Length() + 4
content = Mid$(txt, startPos, (endPos - startPos))
End If
Return content
End Function
'
' *-----
' ** function parseFile - returns an ArrayList of content strings extracted
' ** from the file passed in as an argument
' *-----
Function parseFile(ByVal fileName As String) As ArrayList
Dim arrList As New ArrayList
If System.IO.File.Exists(fileName) = True Then
Dim objReader As New System.IO.StreamReader(fileName)
Dim txLine As String = ""
Do While objReader.Peek() <> -1
txLine = objReader.ReadLine()
If txLine.Contains(BEGIN_PATTERN) Then
Dim content As String = ""
content = extractText(txLine, BEGIN_PATTERN, END_PATTERN)
arrList.Add(content)
End If
Loop
objReader.Close()
Else
Response.Write("This messageboard is currently under construction.")
End If
Return arrList
End Function
'replaced Sub Main with code to generate JavaScript array code
Sub Main()
Dim arr As New ArrayList
arr = parseFile(Server.MapPath("Messageboard.html"))
Dim a As Array = arr.ToArray
Dim sOutput As String = ""
sOutput = "messages=["
For i As Long = 0 To a.Length - 1
sOutput = sOutput + a(i) + ","
Next
sOutput = sOutput + "];"
myLiteralControl.Text = sOutput
End Sub
End Class
 
0
 
LVL 16

Expert Comment

by:sh0e
ID: 22850984
Sorry, it seems I copy/pasted the unfinished version of the NEW code.  I took the liberty of adding single quote escaping code in.  If you still have problems please post the output.

Replace code behind with this:

Partial Class _Default

Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Main()

End Sub

'

' *-----

' ** Constants

' *-----

Dim BEGIN_PATTERN As String = "<!--Begin MessageBoard:Content"

Dim END_PATTERN As String = "<!--End MessageBoard:Content"

'

' *-----

' ** function extractText - returns the text between the start and end tags

' *-----

Private Function extractText(ByVal txt As String, ByVal target1 _

As String, ByVal target2 As String) As String

Dim startPos As Long

Dim endPos As Long

Dim content As String = ""

startPos = InStr(txt, target1)

endPos = InStr(txt, target2)

If startPos = 0 Or endPos = 0 Then

' start or end tag is missing. Set content = "".

content = ""

Else

startPos += target1.Length() + 4

content = Mid$(txt, startPos, (endPos - startPos))

End If

Return content

End Function

 

'

' *-----

' ** function parseFile - returns an ArrayList of content strings extracted

' ** from the file passed in as an argument

' *-----

Function parseFile(ByVal fileName As String) As ArrayList

Dim arrList As New ArrayList

If System.IO.File.Exists(fileName) = True Then

Dim objReader As New System.IO.StreamReader(fileName)

Dim txLine As String = ""

Do While objReader.Peek() <> -1

txLine = objReader.ReadLine()

If txLine.Contains(BEGIN_PATTERN) Then

Dim content As String = ""

content = extractText(txLine, BEGIN_PATTERN, END_PATTERN)

arrList.Add(content)

End If

Loop

objReader.Close()

Else

Response.Write("This messageboard is currently under construction.")

End If

Return arrList

End Function

 

 'replaced Sub Main with code to generate JavaScript array code

Sub Main

Dim arr As New ArrayList

arr = parseFile(Server.MapPath("Messageboard.html"))

Dim a As Array = arr.ToArray

Dim sOutput As String = ""

 

sOutput = "messages=["

 

For i As Long = 0 To a.Length - 1

sOutput = sOutput + "'" + REPLACE(a(i),"'","\'") + "',"

Next 

 

sOutput = sOutput + "];"

myLiteralControl.Text = sOutput

End Sub

End Class

Open in new window

0
 

Author Comment

by:theclassic
ID: 22870245
I replaced the code behind with your file - when I go to run/debug the page, it opens, but you only see two small dots that appear to be the messages starting to scroll, but nothing happens, just still - any ideas - can use the div as an object and then place the literal inside of that?  I am sorry, I don't know the syntax very well - thanks for your help
0
 

Author Comment

by:theclassic
ID: 22870296
I got it, I forgot to place the start messageboard tag in the body tag - but here are the issues, if you can address them.  If I dont hear back, i will award points and repost, but you are the only person who has figured this out, so it would be appreciated -
The messages are appearing out of know where halfway up the div, and then scrolling up, bnot scrolling up from the bottom
 
There is a fourth message that scrolls - the text reads "undefined" - did you set the number of messages anywhere in the code - how can this be altered to get rid of the undefined text
0
 

Author Comment

by:theclassic
ID: 22879760
Hello?
0
 
LVL 16

Expert Comment

by:sh0e
ID: 22883110
Sorry, I have been busy of late, and it's hard to keep track of all the floating threads.
To settle the "undefined", replace the client-side line:
if (currentMessageIndex != messages.length - 1) {
with
if (currentMessageIndex != messages.length - 2) {


As for the "appearing out of nowhere", are you sure the original script works the way you want?
I did not modify any logic other than the messages array.
It sounds to me like a problem with the JavaScript text scroller.
0
 

Author Comment

by:theclassic
ID: 22886863
Is that line something i will have to modify based on the number of messages parsed?Thanks for your help!
0
 
LVL 16

Accepted Solution

by:
sh0e earned 500 total points
ID: 22887705
No, it is in your client-side code.  Replace the corresponding part of resetInnerDiv() function with this:
function resetInnerDiv(){

if (currentMessageIndex != messages.length - 2) {

currentMessageIndex += 1;

} else {

currentMessageIndex = 0;

} 

Open in new window

0
 

Author Closing Comment

by:theclassic
ID: 31510901
I will post if there are any other questions THANKS!!!
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now