Post from Update Panel taking too long

J

John Kotuby

Hi guys,

I have finally added the AJAX extensions to my ASP.NET project in VS 2005
and VB. It was far simpler than I had anticipated, and I wondering why I
didn't use the Update Panel sooner.

Anyway, one of my pages has many controls and populates large DropDown lists
etc.

There are only 2 controls on that page using the update panel now
(listboxes) and a very small set of data needs to be transfered with each
asynchronous postback. The contents of the 2nd listbox is determined by the
user selection in the first listbox. So , I need to update only about 20 or
30 lines of data with each callback. This operation is taking a very long
time compared to a nearly identical operation on a much smaller page.

However, I have read that what happens on the server is an entire page
life-cycle process even with a callback (the server considers it a
postback?). So I am guessing that a whole bunch of things are going on that
I really don't need.

Other than using "If Not Page.IsPostback" to cut down on the server side
processing, is there any way to tell the server to just run a particular Sub
or Function during the callback?

I would like to stay away from web services if possible to avoid another
learning curve.

Point me to a resource if there is one that is directly related to my
particular concern.

Or are there any other suggestions?

TIA
 
D

dev

Hi guys,

I have finally added the AJAX extensions to my ASP.NET project in VS 2005
and VB. It was far simpler than I had anticipated, and I wondering why I
didn't use the Update Panel sooner.

Anyway, one of my pages has many controls and populates large DropDown lists
etc.

There are only 2 controls on that page using the update panel now
(listboxes) and a very small set of data needs to be transfered with each
asynchronous postback. The contents of the 2nd listbox is determined by the
user selection in the first listbox. So , I need to update only about 20 or
30 lines of data with each callback. This operation is taking a very long
time compared to a nearly identical operation on a much smaller page.

However, I have read that what happens on the server is an entire page
life-cycle process even with a callback (the server considers it a
postback?). So I am guessing that a whole bunch of things are going on that
I really don't need.

Other than using "If Not Page.IsPostback" to cut down on the server side
processing, is there any way to tell the server to just run a particular Sub
or Function during the callback?

I would like to stay away from web services if possible to avoid another
learning curve.

Point me to a resource if there is one that is directly related to my
particular concern.

Or are there any other suggestions?

TIA

Hi,

When you are using update panel. Is the process not fast. Sorry will
you please explain more.

Thanks
Net
 
J

John Kotuby

Hi dev,
Here is the code in my ASPX page where I am using the Update panel.
------------------------------------------------------------------
<asp:ScriptManager ID="ScriptManager1" runat="server"
EnablePartialRendering="true">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<table class="TblSearch" width="98%" cellpadding="0" cellspacing="0"
border="0">
<tr>
<td align="center" style=" width:30%" >
<asp:ListBox ID="lstCategoryType" SelectionMode="Single" runat="server"
CssClass="txt95"
OnSelectedIndexChanged="lstCategoryType_SelectedIndexChanged"
AutoPostBack="true" Rows="6">
</asp:ListBox>
</td>
<td align="center" style=" width:70%" >
<asp:ListBox ID="lstCategories" SelectionMode="Multiple" runat="server"
Rows="6" CssClass="txt95"></asp:ListBox>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
------------------------------------------------------------------
Note that in the ListBox ID="lstCategoryType" I have set
AutoPostback="True", because if I don't do that the update of the 2nd
listbox does not appear to occur. I have also set
OnSelectedIndexChanged="lstCategoryType_SelectedIndexChanged". Also I have
EnablePartialPageRendering="true" in the ScriptManager.

There are about 40 other controls on this page that are NOT in the
UpdatePanel.

Now here is the Code Behind method I wish to run:
---------------------------------------------------------------
Protected Sub lstCategoryType_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs)

'Load the lstCategories ListBox according to the selected CategoryType
Dim lstValue, lstText As String
Dim MyConnection As New SqlConnection
Dim MyCommand As New SqlCommand
Dim MyAdapter As New SqlDataAdapter
Dim CatTable As New DataTable

MyConnection.ConnectionString =
ConfigurationManager.ConnectionStrings("PCConnectionString").ConnectionString
MyConnection.Open()
MyCommand.CommandType = CommandType.Text
MyCommand.Connection = MyConnection

MyCommand.CommandText = "Select code,description from CategoryTable
with(nolock)where " & _
" categorytype ='" & Me.lstCategoryType.SelectedValue & "' order by
description "

MyAdapter.SelectCommand = MyCommand
MyAdapter.Fill(CatTable)

Me.lstCategories.Items.Clear()

For Each row As DataRow In CatTable.Rows
lstValue = row.Item("code").ToString
lstText = row.Item("description").ToString & " (" &
row.Item("code").ToString + ")"
Me.lstCategories.Items.Add(New ListItem(lstText, lstValue))
Next

MyAdapter.Dispose()
MyCommand.Dispose()
MyConnection.Dispose()
CatTable.Dispose()
End Sub
---------------------------------------------------------------

Now If I could get only that method to run and populate just the
lstCategories listbox that would be great. But it appears that a lot of
other code is also running because the refresh of the data in the listbox is
slow. It takes 5 seconds to refresh. Remember there are 40 other server
controls on this page that are outside of the Update Panel.

I compare the refresh time to a much smaller page with only 6 server
controls on it, all in an update panel, and the code-behind (that handles
the SelectedIndexChanged event) is almost identical. This page takes less
than 1 second to refresh the listbox.

Same database, same query, same web server. The slow page, like I said,
simply has many more controls on it, but only the 2 listboxes are in the
Update Panel.
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top