S
Steve
Hello,
I have been experimenting/learning to use aspx with and
without VS2003. In VS 2003 I created a simple
webform/application which contains a listbox and a label.
I populate the listbox and on the
"OnSelectedIndexChanged="lstProducts_SelectedIndexChanged"
event of the listbox (called in the html section) I write
the value/index in the label for the selected item.
In the VS 2003 app I don't need to add
"OnSelectedIndexChanged="lstProducts_SelectedIndexChanged"
to the <asp:listbox... tag in the html section because the
code region has WithEvents declarations.
But in a standalone aspx I have to add the event call
"OnSelectedIndexChanged="lstProducts_SelectedIndexChanged"
to the listbox tag in the html section to get the click
event. I tried Dim WithEvents ListBox1... in the script
section of the aspx (and removed the event call in the
<asp:listobx tag of the html section) but got an error
message that ListBox1 was already declared -- except the
declaration did not include WithEvents and I did not have
a click event without the event call in the
<asp:listbox...tag. So if it is possible to use
WithEvents in a Standalone aspx, how would I declare
ListBox1 WithEvents? Here is what I have already tried:
<%@ Import Namespace="System.IO" %>
<script language="VB" runat="server">
Dim WithEvents ListBox1 As
System.Web.UI.WebControls.ListBox
Sub Page_Load(Src as Object, E as EventArgs)
If Not IsPostBack Then
.... populate ListBox1
End Sub
Sub ListBox1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs)
Label1.Text = "You selected " &
ListBox1.SelectedItem.Text
End Sub
Thanks,
Steve
I have been experimenting/learning to use aspx with and
without VS2003. In VS 2003 I created a simple
webform/application which contains a listbox and a label.
I populate the listbox and on the
"OnSelectedIndexChanged="lstProducts_SelectedIndexChanged"
event of the listbox (called in the html section) I write
the value/index in the label for the selected item.
In the VS 2003 app I don't need to add
"OnSelectedIndexChanged="lstProducts_SelectedIndexChanged"
to the <asp:listbox... tag in the html section because the
code region has WithEvents declarations.
But in a standalone aspx I have to add the event call
"OnSelectedIndexChanged="lstProducts_SelectedIndexChanged"
to the listbox tag in the html section to get the click
event. I tried Dim WithEvents ListBox1... in the script
section of the aspx (and removed the event call in the
<asp:listobx tag of the html section) but got an error
message that ListBox1 was already declared -- except the
declaration did not include WithEvents and I did not have
a click event without the event call in the
<asp:listbox...tag. So if it is possible to use
WithEvents in a Standalone aspx, how would I declare
ListBox1 WithEvents? Here is what I have already tried:
<%@ Import Namespace="System.IO" %>
<script language="VB" runat="server">
Dim WithEvents ListBox1 As
System.Web.UI.WebControls.ListBox
Sub Page_Load(Src as Object, E as EventArgs)
If Not IsPostBack Then
.... populate ListBox1
End Sub
Sub ListBox1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs)
Label1.Text = "You selected " &
ListBox1.SelectedItem.Text
End Sub
Thanks,
Steve