Post from Update Panel taking too long
am 27.12.2007 15:49:48 von 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
Re: Post from Update Panel taking too long
am 27.12.2007 22:11:25 von dev
On Dec 27, 9:49 am, "John Kotuby"
wrote:
> 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
Re: Post from Update Panel taking too long
am 27.12.2007 22:42:00 von John Kotuby
Hi dev,
Here is the code in my ASPX page where I am using the Update panel.
------------------------------------------------------------ ------
EnablePartialRendering="true">
border="0">
CssClass="txt95"
OnSelectedIndexChanged="lstCategoryType_SelectedIndexChanged "
AutoPostBack="true" Rows="6">
|
Rows="6" CssClass="txt95">
|
------------------------------------------------------------ ------
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.
"dev" wrote in message
news:e33c3df8-638b-4962-a38c-90795647ecbc@s19g2000prg.google groups.com...
> On Dec 27, 9:49 am, "John Kotuby"
> wrote:
>> 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