PC Review


Reply
Thread Tools Rate Thread

Configure Update Panel to run a particular method only?

 
 
John Kotuby
Guest
Posts: n/a
 
      12th Jan 2008
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...

 
Reply With Quote
 
 
 
 
Mike Placentra II
Guest
Posts: n/a
 
      12th Jan 2008
On Jan 12, 3:13 pm, "John Kotuby" <jo...@powerlist.com> wrote:
> 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?


"Startup code" should usually be run in a conditional block. You can
check the value of Page.IsPostBack.

-Mike Placentra II
 
Reply With Quote
 
Milosz Skalecki [MCAD]
Guest
Posts: n/a
 
      14th Jan 2008
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...
>
>

 
Reply With Quote
 
jkotuby
Guest
Posts: n/a
 
      22nd Jan 2008
Thanks Milosz,
That tuorial was very helpful. Sorry I didn't respond sooner...got
busy.

On Jan 13, 8:43*pm, Milosz Skalecki [MCAD] <mily...@DONTLIKESPAMwp.pl>
wrote:
> 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
>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Please go to control panel and configure system components. deertroy Windows XP General 3 16th Jun 2008 02:37 PM
Please go to the Control Panel and configure the system component =?Utf-8?B?QWxhbiBBdWd1c3R1cw==?= Windows XP Help 1 1st Nov 2007 05:39 PM
Please go to the control panel to install and configure system com =?Utf-8?B?R3JhbmE=?= Microsoft Dot NET 1 21st Sep 2007 12:39 PM
Re: Using VBA to configure the Navigation Panel Ken Slovak - [MVP - Outlook] Microsoft Outlook VBA Programming 0 20th Feb 2007 02:50 PM
RemotingConfiguration.Configure Method Headache Mantorok Microsoft ASP .NET 0 18th Feb 2005 10:25 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:45 AM.