ajwei810192 10 Junior Poster in Training

Hi,

I have a question regarding an issue on submitting a form multiple times. For some reason, my form takes one submit, but then the others, I don't see changes of result. Here is the app:

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.XML" %>

<script runat="server">   

Sub submit(ByVal sender As Object, ByVal e As EventArgs)
              
    mess.Text = "You selected " & drop1.SelectedItem.Text 
    Dim file As String = Context.Server.MapPath("music.xml") 
    Dim document As XmlDocument = New XmlDocument() 
    document.Load(file) 

    Dim songList As XmlNodeList 
    songList = document.SelectNodes("/music_songs/song[category='" & drop1.SelectedItem.Text & "']")    

    Dim song As XmlNode
    For Each song In songList
    
    Dim title As XmlNode = song.FirstChild
    songNodesOut.Text &=  "<b>Title:</b> " & title.InnerText & "<br/>"

    Dim category As XmlNode = title.NextSibling
    SongNodesOut.Text &= "<b>Category:</b> " & category.InnerText & "<br /><hr />"
    
  Next
		
end Sub
</script>

<html>
<body>
<form runat="server">

<div>
<asp:DropDownList id="drop1" runat="server">
<asp:ListItem>Rock</asp:ListItem>
<asp:ListItem>Blues</asp:ListItem>
</asp:DropDownList>
<asp:Button Text="Submit" OnClick="submit" runat="server"/>
</form>

<p><asp:label id="mess" runat="server"/></p>
<asp:Label id="songNodesOut" runat="server" />
</div>
</body>
</html>

In other words, if I first make Rock as my selection from drop down list, the songs are listed correctly, but if I try and select on the Blues, even though those songs exist, I only see the same songs from the other list. Is there something here that I missed?

Thanks for your help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.