<%@ Page Language="VB" Debug="true" %>
<script runat="server">
Sub Page_Load (Sender As Object, E As EventArgs)
Dim MyFileName as String
Dim ObjectStreamReader as System.IO.StreamReader
Dim FileLines as New ArrayList()
MyFileName = Page.MapPath("Data.txt")
Try
ObjectStreamReader = new System.IO.StreamReader (MyFileName)
While ObjectStreamReader.Peek() > -1
FileLines.Add(ObjectStreamReader.ReadLine())
End While
FileLines.Sort()
Label1.Text = "Select a title:"
DropDownList1.DataSource = FileLines
DropDownList1.DataBind()
Catch ObjectError as Exception
Label1.Text = ObjectError.Message
DropDownList1.Visible = False
Finally
If Not ObjectStreamReader Is nothing Then
ObjectStreamReader.Close()
End If
End Try
End Sub
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:Label id="Label1" runat="server"></asp:Label>
<asp:DropDownList id="DropDownList1" runat="server"></asp:DropDownList>
</form>
</body>
</html>
|