Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / December 2007

Tip: Looking for answers? Try searching our database.

Post from Update Panel taking too long

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Kotuby - 27 Dec 2007 14:49 GMT
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
dev - 27 Dec 2007 21:11 GMT
On Dec 27, 9:49 am, "John Kotuby"
<JohnKot...@discussions.microsoft.com> wrote:
> Hi guys,
>
[quoted text clipped - 30 lines]
>
> TIA

Hi,

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

Thanks
Net
John Kotuby - 27 Dec 2007 21:42 GMT
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.

> On Dec 27, 9:49 am, "John Kotuby"
> <JohnKot...@discussions.microsoft.com> wrote:
[quoted text clipped - 46 lines]
> Thanks
> Net

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.