error when using <% %>and <script></script> tags

K

-Karl

Couls someone please advise me on this error. What I am trying to do
is be able to convert an XML document into arrays. I read that the
subs & functions have to be in <script> tags.

Thanks!



Error:
BC30456: 'Read_DOM' is not a member of
'ASP.maps_examples_xml_to_array_aspx'.
Line 53: <asp:Button Text="Read DOM" OnClick="Read_DOM" runat="server"/

Code:
<%@ Import Namespace="System.Xml" %>

<%
Dim randNumbers(1) as Integer
randNumbers(0) = 5

Dim XMLDocument = New XmlDocument
Dim NodeReader = New XmlNodeReader(XMLDocument)

XMLDocument.Load(MapPath("XMLSample.xml"))

While NodeReader.Read()

Dim Spaces As String = Indent(NodeReader.Depth)

If NodeReader.IsStartElement() Then
DOMOut.Text &= "<br/>" & Spaces & "<b>" & NodeReader.Name & "</b>"
DOMOut.Text &= " [Depth: " & NodeReader.Depth & "]"
End If

If NodeReader.NodeType = XmlNodeType.Text Then
DOMOut.Text &= "<b>: </b>" & NodeReader.Value
End If

'List all trees


If NodeReader.Depth = 1 Then
Lbl_Trees.text &= NodeReader.Name & " | "

End if
End While

NodeReader.Close()
%>


<script runat="server" language="vb">

Function Indent(Depth As Integer)

Dim i As Integer
Dim Spaces As String
For i = 1 to Depth
Spaces &= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
Next
Return Spaces

End Function
</script>

<form runat=server>
<asp:Button Text="Read DOM" OnClick="Read_DOM" runat="server"/>
<P>
<asp:Label id="DOMOut" EnableViewState="False" runat="server"/>
<P>
<asp:Label id="Lbl_Trees" EnableViewState="False" runat="server"/>
</form>
 
C

Cubaman

Couls someone please advise me on this error. What I am trying to do
is be able to convert an XML document into arrays. I read that the
subs & functions have to be in <script> tags.

Thanks!

Error:
BC30456: 'Read_DOM' is not a member of
'ASP.maps_examples_xml_to_array_aspx'.
Line 53: <asp:Button Text="Read DOM" OnClick="Read_DOM" runat="server"/



Code:
<%@ Import Namespace="System.Xml" %>

<%
Dim randNumbers(1) as Integer
randNumbers(0) = 5

Dim XMLDocument = New XmlDocument
Dim NodeReader = New XmlNodeReader(XMLDocument)

XMLDocument.Load(MapPath("XMLSample.xml"))

While NodeReader.Read()

Dim Spaces As String = Indent(NodeReader.Depth)

If NodeReader.IsStartElement() Then
DOMOut.Text &= "<br/>" & Spaces & "<b>" & NodeReader.Name & "</b>"
DOMOut.Text &= " [Depth: " & NodeReader.Depth & "]"
End If

If NodeReader.NodeType = XmlNodeType.Text Then
DOMOut.Text &= "<b>: </b>" & NodeReader.Value
End If

'List all trees

If NodeReader.Depth = 1 Then
Lbl_Trees.text &= NodeReader.Name & " | "

End if
End While

NodeReader.Close()
%>

<script runat="server" language="vb">

Function Indent(Depth As Integer)

Dim i As Integer
Dim Spaces As String
For i = 1 to Depth
Spaces &= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
Next
Return Spaces

End Function
</script>

<form runat=server>
<asp:Button Text="Read DOM" OnClick="Read_DOM" runat="server"/>
<P>
<asp:Label id="DOMOut" EnableViewState="False" runat="server"/>
<P>
<asp:Label id="Lbl_Trees" EnableViewState="False" runat="server"/>
</form>

Well, functions and subs have to be in <script> tags. Anyway, from an
architectural point of view, you are implementing bussines logic in a
page. Whay don't you move this code to another class and make it
reusable from all over the application? And why you don't use code-
behind's visual studio feature to separete code from presentation?
Good luck.
 
K

-Karl

Couls someone please advise me on this error. What I am trying to do
is be able to convert an XML document into arrays. I read that the
subs & functions have to be in <script> tags.

Error:
BC30456: 'Read_DOM' is not a member of
'ASP.maps_examples_xml_to_array_aspx'.
Line 53: <asp:Button Text="Read DOM" OnClick="Read_DOM" runat="server"/
Code:
<%@ Import Namespace="System.Xml" %>
<%
Dim randNumbers(1) as Integer
randNumbers(0) = 5
Dim XMLDocument = New XmlDocument
Dim NodeReader = New XmlNodeReader(XMLDocument)

While NodeReader.Read()
Dim Spaces As String = Indent(NodeReader.Depth)
If NodeReader.IsStartElement() Then
DOMOut.Text &= "<br/>" & Spaces & "<b>" & NodeReader.Name & "</b>"
DOMOut.Text &= " [Depth: " & NodeReader.Depth & "]"
End If
If NodeReader.NodeType = XmlNodeType.Text Then
DOMOut.Text &= "<b>: </b>" & NodeReader.Value
End If
'List all trees
If NodeReader.Depth = 1 Then
Lbl_Trees.text &= NodeReader.Name & " | "
End if
End While

<script runat="server" language="vb">
Function Indent(Depth As Integer)
Dim i As Integer
Dim Spaces As String
For i = 1 to Depth
Spaces &= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
Next
Return Spaces
End Function
</script>
<form runat=server>
<asp:Button Text="Read DOM" OnClick="Read_DOM" runat="server"/>
<P>
<asp:Label id="DOMOut" EnableViewState="False" runat="server"/>
<P>
<asp:Label id="Lbl_Trees" EnableViewState="False" runat="server"/>
</form>

Well, functions and subs have to be in <script> tags. Anyway, from an
architectural point of view, you are implementing bussines logic in a
page. Whay don't you move this code to another class and make it
reusable from all over the application? And why you don't use code-
behind's visual studio feature to separete code from presentation?
Good luck.- Hide quoted text -

- Show quoted text -

I am coding this via a notepad like editor. I don't use VS and I
haven't yet look into code behinds (Somewhat complex right now)
What do you mean by seperate class?
I was wanting to keep this piece together for simplicity of managing
the code. I am not planning on reusing this code anywhere in my
project but I understand the value of making this a function for
future use.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top