T
teo
I have a Listbox,
if I set
EnableViewStarte = False
the
AutopostaBack fired by SelectedIndexChanged
doesn't work.
The 'SelectedIndexChanged' event should call
a sub called 'SayHalloPlease'.
Any Idea?
Here my simple code:
a Button
a Listbox
a Textbox
with Listbox EnableViewState = True it works
with Listbox EnableViewState = False it doesn't work
( AspNet 20 VisualStudio 2005 )
--- here the Code behind: ---------------------------------
Protected Sub ListBox1_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
MsgBox("I've been fired!")
SayHalloPlease(ListBox1.SelectedIndex)
End Sub
Private Sub SayHalloPlease(ByVal myNumber As Integer)
If myNumber = 2 Then TextBox1.Text = TextBox1.Text & "Hallo"
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
ListBox1.Items.Add("aaaaa")
ListBox1.Items.Add("bbbbb")
ListBox1.Items.Add("cccccThis")
ListBox1.Items.Add("ddddd")
ListBox1.Items.Add("eeeee")
End Sub
---- here the Asp code: -------------------------------------
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"
Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Pagina senza titolo</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ListBox ID="ListBox1" runat="server" AutoPostBack="True"
Style="z-index: 100; left: 284px; position: absolute; top:
40px">
</asp:ListBox>
<asp:Button ID="Button1" runat="server" Style="z-index: 102; left:
164px; position: absolute;
top: 48px" Text="Button" />
<asp:TextBox ID="TextBox1" runat="server" Style="z-index: 104;
left: 472px; position: absolute;
top: 64px"></asp:TextBox>
</div>
</form>
</body>
</html>
if I set
EnableViewStarte = False
the
AutopostaBack fired by SelectedIndexChanged
doesn't work.
The 'SelectedIndexChanged' event should call
a sub called 'SayHalloPlease'.
Any Idea?
Here my simple code:
a Button
a Listbox
a Textbox
with Listbox EnableViewState = True it works
with Listbox EnableViewState = False it doesn't work
( AspNet 20 VisualStudio 2005 )
--- here the Code behind: ---------------------------------
Protected Sub ListBox1_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
MsgBox("I've been fired!")
SayHalloPlease(ListBox1.SelectedIndex)
End Sub
Private Sub SayHalloPlease(ByVal myNumber As Integer)
If myNumber = 2 Then TextBox1.Text = TextBox1.Text & "Hallo"
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
ListBox1.Items.Add("aaaaa")
ListBox1.Items.Add("bbbbb")
ListBox1.Items.Add("cccccThis")
ListBox1.Items.Add("ddddd")
ListBox1.Items.Add("eeeee")
End Sub
---- here the Asp code: -------------------------------------
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"
Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Pagina senza titolo</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ListBox ID="ListBox1" runat="server" AutoPostBack="True"
Style="z-index: 100; left: 284px; position: absolute; top:
40px">
</asp:ListBox>
<asp:Button ID="Button1" runat="server" Style="z-index: 102; left:
164px; position: absolute;
top: 48px" Text="Button" />
<asp:TextBox ID="TextBox1" runat="server" Style="z-index: 104;
left: 472px; position: absolute;
top: 64px"></asp:TextBox>
</div>
</form>
</body>
</html>