Listbox vs DropDown

M

Micke Palm

Hello!

I've done a little test. I try to fill up a listbox (dropdown) with 35000
posts. Check the code below and it's works fine ,but when I want do the same
thing with apsnet ,but in aspnet way it hangs.
The ASP code

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title></title>
</head>
<body>
<form method="POST" action="--WEBBOT-SELF--">

<p><select size="5" name="D1" multiple>
<%
for tt = 0 to 35000
sData = "123456789123456789 Number = " & CStr(tt) %>
<option><% =sData %></option>
<%
iBytes = iBytes + Len(sData)
next
%>
</select>
<% response.Write "Bytes: " & iBytes %>
</p>
</form>

</body>
</html>

The ASPNET code...You must have webcontrols like ListBox1 and Label1

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here

Dim iBytes As Integer
Dim sData As String

If Not IsPostBack Then

Dim tt As Integer
For tt = 0 To 14000
sData = "123456789123456789 Number = " & CStr(tt)

'sData = tt
ListBox1.Items.Add(New ListItem(sData, CStr(tt)))
iBytes += Len(sData)
Next tt
Label1.Text = "Count of characters: " & iBytes
End If
End Sub

Do anyone have any ideas why ASPNET is so much slower and hangs after a
while. 10000 works fine but not 14000 and it depends on how much data I've
for each row. So I guess it checking how much data it is in the listbox.
A strange thing is that ASP is much faster than ASPNET in this case??

/regards, micke
 
K

Ken Cox [Microsoft MVP]

Hi Micke,

It doesn't choke on my system. My guess is that on yours, ASP.NET is trying
to maintain the Viewstate of those controls and going berserk with the
volume.

It seems to work fine with EnableViewState="False". Are you able to turn off
the viewstate? Do you really need it - especially since you didn't have in
in ASP Classic?

<P>
<asp:ListBox id="ListBox1" runat="server"
EnableViewState="False"></asp:ListBox></P>
<P>
<asp:Label id="Label1" runat="server"
EnableViewState="False">Label</asp:Label></P>

Ken
 
M

Micke Palm

I found the problem!

It was Norton Personal Firewall wich hang up my computer. I've spent days to
check what's wrong with server, IE and ASP.NET så here it goes. UNINSTALL
NORTON ;)
Thanks anyway for your help. I will check viewstate property too...

Regards, Micke
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top