Hi John,
Several posibilities- you could read IsInPartialRendering property of the
UpdatePanel to determine if a particular panel is being refreshed ie:
if (myPanel1.IsinparyialRendering)
{
}
or even better, use client-side ajax scripting to populate the lisbox
-- begin asp code --
<asp:ScriptManager runat="server" ID="manager" EnablePageMethods="true" />
Manufacturer:
<asp:ListBox runat="server" ID="list1" OnChange="Populate(this)">
<asp:ListItem Text="Audi" Value="Audi" />
<asp:ListItem Text="Porsche" Value="Porsche" />
<asp:ListItem Text="Ford" Value="Ford" />
<asp:ListItem Text="Honda" Value="Honda" />
</asp:ListBox>
Car:
<asp:ListBox runat="server" ID="list2" />
<asp:Button runat="server" ID="btnSubmit" Text="Submit" />
<script type="text/javascript">
function Populate(list)
{
PageMethods.GetCars(list.options[list.selectedIndex].value,
OnSuccess, OnError, OnTimeOut);
}
function OnSuccess(cars)
{
var list2 = $get('<%= list2.ClientID %>');
list2.options.length = 0;
for (var i = 0; i < cars.length; i++)
{
list2.options[i] = new Option(cars[i], cars[i]);
}
}
function OnError(result)
{
alert('Error : ' + result.get_message());
}
function OnTimeOut(result)
{
alert('Sorry, timeout!');
}
</script>
-- end aspx code --
-- begin c# code beside --
[System.Web.Services.WebMethod(false)]
[System.Web.Script.Services.ScriptMethod(UseHttpGet = true)]
public static string[] GetCars(string manufacturer)
{
string[] cars = new string[10];
for (int i = 0; i < cars.Length; i++)
{
cars[i] = manufacturer + " car " + i.ToString();
}
return cars;
}
-- end c'# code beside --
or just to check eventtarget hidden field value (of course when using
UpdatePanels and ListBox1.AutoPostBack set to true):
bool list1SelectedIndexChanged =
Request[postEventSourceID] == list1.UniqueID;
hope this helps
--
Milosz
"John Kotuby" wrote:
> Hi all,
> I have an update panel that holds only 2 listBoxes in a page surrounded by
> 40 other controls.
> The purpose of the panel is -- select an Item in ListBox1 and update the
> contents in ListBox2.
> I have Autopostback="true" on ListBox1.
> Even though ListBox2 is actually the only thing refreshing on the page, as
> expected, I am pretty sure that a lot of the startup code to the page is
> also running unneccesarily, causing a long delay.
>
> Can someone give me a quick pointer on how to tell the page to run just the
> SelectedIndexChanged code when the postback is the result of the ListBox1
> within the Updatepanel?
>
> A link to an article that targets this question would be fine.
>
> Thanks for any help...
>
>
|