|
Rank: Member Groups: Member
Joined: 6/21/2007 Posts: 15
|
Ok I know this is going to sound strange but here goes.
I am using a callback panel with four drop downs. We are doing a Country, State/Prov, City, Zip/Postal lookup from SQL Server.
When the user selects the country it populates the State/Prov. Then the user selects the State/Prov and it populates the city. Right down the list until we finish with the zip/postal code.
I have a panel setup to let the user know when it is loading and it disables all controls on the panel when each dropdown is loading.
Ok now for my problem. Certain times when a dropdown is selected there is a long delay (more than 5 to 10 secs) before it notifies the user that it is loading. It does not happen all the time. I have tested it without the callback panel just doing postbacks and it works fine with no delay.
If you could maybe shed some light on this problem I would appreciate it.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi Paul,
Check your view state data size. Most of the time, when the CallbackPanel "chokes", it "chokes" on view state. CallbackPanel performance can benefit if you can dramatically reduce view state size.
If that does not solve the problem, we would need you to create a sample application that duplicates the problem so that we can look into it at here and see if we can get to the bottom of it.
Thanks
|
|
Rank: Member Groups: Member
Joined: 6/21/2007 Posts: 15
|
Ok to see an example of this problem go to url [removed for privacy] Please note: You must play with it for a while before you will see the problem. Really weird.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
I looked the page and the view state data is HUGE. You definitely will want to reduce it. Try to: 1. Set the combobox's EnableViewState to false; 2. Re-populate the combobox every time, for example, if your previous code is:
Code: C#
private void Page_Load(object sender, EventArgs e)
{
if (!Page.PostBack)
FillCountryList();
}
Change it to:
Code: C#
private void Page_Load(object sender, EventArgs e)
{
FillCountryList();
}
|
|
Rank: Member Groups: Member
Joined: 6/21/2007 Posts: 15
|
The problem with that approach is that it will not keep the users last selection. So when the list repopulates it wipes out all the other selections.
Here is the code used to populate the dropdowns. Sorry for the formating issues.
Imports System.Data.sqlclient Partial Class firstfields Inherits System.Web.UI.UserControl Protected Sub state_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles state.SelectedIndexChanged Dim sqltemp As String = "" Dim myreader As SqlDataReader sqltemp = "select distinct city from city with (nolock) where state='" + fixstring(state.SelectedValue) + "' order by city" Response.Write(sqltemp) city.Items.Clear() myreader = runsqlquery(sqltemp) While myreader.Read city.Items.Add(myreader.Item("city")) End While myreader.Close() End Sub Protected Sub country_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles country.SelectedIndexChanged Dim sqltemp As String = "" Dim myreader As SqlDataReader sqltemp = "select distinct stateprov from states with (nolock) where country='" + fixstring(country.SelectedValue) + "'" state.Items.Clear() myreader = runsqlquery(sqltemp) While myreader.Read state.Items.Add(myreader.Item("stateprov")) End While myreader.Close() sqltemp = "select distinct city from city with (nolock) where state='" + fixstring(state.SelectedValue) + "' order by city" city.Items.Clear() myreader = runsqlquery(sqltemp) While myreader.Read city.Items.Add(myreader.Item("city")) End While myreader.Close() End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim sqltemp As String = "" Dim myreader As SqlDataReader 'meme.Visible = False sqltemp = "select * from countrytbl with (nolock) order by country" If Not IsPostBack Then myreader = runsqlquery(sqltemp) While myreader.Read() country.Items.Add(myreader.Item("country")) End While country.SelectedValue = "United States" myreader.Close() sqltemp = "select stateprov from states with (nolock) where country='United States' order by stateprov" myreader = runsqlquery(sqltemp) While myreader.Read() state.Items.Add(myreader.Item("stateprov")) End While myreader.Close() sqltemp = "select distinct city from city with (nolock) where state='AK'" myreader = runsqlquery(sqltemp) While myreader.Read() city.Items.Add(myreader.Item("city")) End While myreader.Close() End If End Sub End Class
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi Paul,
Do the populating in Page_Init instead of Page_Load. That should help you to keep user selection.
Thanks
|
|
Rank: Member Groups: Member
Joined: 6/21/2007 Posts: 15
|
I just changed the code to load on the INIT rather than the page load. I also disabled the viewstate on all the dropdowns. The problem is still happening and it does not look like a view state issue because the view state is really small. Have a look for yourself.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
I need your link again. Can you PM to me? Sorry that I didn't keep it.
|
|
Rank: Member Groups: Member
Joined: 6/21/2007 Posts: 15
|
I PM'ed it to you. Let me know if you did not get it.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
I looked into your code and noticed that it slowed not after you made a few selection, but slowed after you selected certain counties. Try select "Argentina" and then select another country, you will see it choke immediately.
We debugged the code and found that you've populated 3114 cities to the city drop down for "Buenos Aires" in "Argentina". That huge number of cities is causing it to choke up.
|
|
Rank: Member Groups: Member
Joined: 6/21/2007 Posts: 15
|
I see your point but I do not have a work around for that. If the control notified the user immediately it would not be and issue because it would say loading... and the user would know they had to wait. But what is happening is it just seems to hang with no indication that something is happening until it finishes. Any idea's?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Given the size of your data I do not think there is a simple solution to this. Our CallbackPanel code actually displays the loading message right after you changed the selection, but IE doesn't update the screen for a long time because its too busy counting the cities. Complicated solution is possible but having user to pick one out of 3114 items from a listbox probablly won't work for the user anyway. So you may still want to tackle the problem from that front. If that is not an option, you can try this way: 1. Set the country listbox's AutoPostBack to false; 2. Attach a client side event handler to the listbox's onchange event, say the name is countryChanged; 3. Inside your onchange event, you will: a. Display status information, b. Set a timer to call another function to triger the callback. The final code will be something like this:
Code: JavaScript
function countryChanged()
{
var statusPanel = document.getElementById("statusPanel");
statusPanel.innerHTML = "Loading";
window.setTimeout("eo_Callback('Callback1')", 200);
}
The timer is important so that IE can get a "break" to actually refresh the screen to display the status message. You may need to delay it longer. However this introduces a gap in which user will still be able to make another selection, which is not what you wanted. If you want to prevent that, you can displays a modal dialog box using our dialog control instead of changing statusPanel.innerHTML.
|
|
Rank: Member Groups: Member
Joined: 6/21/2007 Posts: 15
|
Sounds like this approach may work for me. I am not so concerned about the user picking another selection as I am concerned that they are informed that the dropdown is loading and they need to wait. If they see a loading... indication they will probably not attempt to pick something else until it is complete. Even if they do it will not really matter. Once again your support has been outstanding and I thank you for the lightning speed of your reply.
I will let you know later today if this approach works for me.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Glad to hear that you like our support! We work very hard to offer both fast and accurate reponse. :)
|
|