By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,089 Members | 1,964 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,089 IT Pros & Developers. It's quick & easy.

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

P: n/a
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 <scripttags.

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>

Jun 15 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Jun 15, 9:43 am, -Karl <dino...@gmail.comwrote:
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 <scripttags.

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 <scripttags. 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.

Jun 17 '07 #2

P: n/a
On Jun 17, 10:48 am, Cubaman <oscar.acostamonte...@googlemail.com>
wrote:
On Jun 15, 9:43 am, -Karl <dino...@gmail.comwrote:


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 <scripttags.
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 <scripttags. 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.


Jun 18 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.