Wednesday, March 28, 2012

Multiple UpdateProgress Controls

Hi,

Does anyone know if there are plans to allow for multiple UpdateProgress controls in a future release of Atlas? This is an important requirement for most Ajax sites as activity indicators are usually located near the control that triggered the postback.

I have seen a workaround that allows you to do it using a combination of JS and CSS but it would be great if this was automatically available in the framework.

Cheers,

Jason

Do it easily using bindings in the aspx code :

<div id="myProgressUdpate1" >Data Loading</div>
<div id="myProgressUdpate2" >Data Loading</div
<script type="text/xml-script">
<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
<components>
<control id="myProgressUdpate1">
<bindings>
<binding dataContext="_PageRequestManager" dataPath="inPostBack" property="visible" />
</bindings>
</control>
<control id="myProgressUdpate2">
<bindings>
<binding dataContext="_PageRequestManager" dataPath="inPostBack" property="visible" />
</bindings>
</control>
</components>
</page>
</script>

hello.

hum...i think he wanted a solution where only one updatepanel would be show. i think that currently this won't be possible (ie, writting generic code that works in all cases) because you can't get a reference to the updatepanel that is "responsible" for the download.

if the team changes the pagerequestmanager class slightly so that it let us access the posback settings, it would be easy to get that info...


Yes, I do only want one of the updateprogress controls to show depending on the control that triggered the postback. Maybe the UpdateProgress control could be enhanced to allow triggers to be assigned in a similar way to UpdatePanels so that they only show when certain events or conditions occur.
Does anyone from MS have a comment on this one...this is a must-have feature for most AJAX apps?
I would agree, I just tried to accomplish this and without doing a lot of fancy javascript to figure out where the user clicked and show it in the right spot based on what and where things were clicked on I couldn't get it to work. Sure would be nice if UpdateProgress controls could be bound to UpdatePanel controls.

Note this is a supported scenario since ASP.NET AJAX beta 1 with "Value-Add" CTP:
You can have multiple UpdateProgress controls on a page that can run conditionally based on which UpdatePanel callback is occurring.


Thanks...I noticed this in the release notes and it is an excellent enhancement.


Would be even better if we could attach an UpdateProgress to multiple UpdatePanel...!

AssociatedUpdatePanelID="updatePanel1, updatePanel2"


Some people are just never happy ;-)

You're right though...that would be a useful extension to save duplicating the UpdateProgress controls. I can think of at least one case where I could use that although I will probably just locate an UpdateProgress control in "neutral" territory.


Why not make your lives easier and put your UpdateProgress into a UserControl that you can just drag and drop in? Works a LOT easier IMO.

Pluginbaby:

Note this is a supported scenario since ASP.NET AJAX beta 1 with "Value-Add" CTP:
You can have multiple UpdateProgress controls on a page that can run conditionally based on which UpdatePanel callback is occurring.

has anyone actually gotten this to work with either the beta 1 or beta 2 release? when i specify a value for the AssociatedUpdatePanelID property, the UpdateProgress control never appears.

thanks


Yeah...it is working for me in beta 1 although I do have to use the ClientID of the UpdatePanel control rather than just its ID, so if you are using MasterPages, it will look something like "ctl00_ContentPlaceHolder_UpdatePanel". I am therefore setting the AssociatedUpdatePanelID in the Page_Load event using UpdatePanel.ClientID so that I don't have to worry about any changes in the control hierarchy.

I had a number of problems with beta 2 and had to rollback to beta 1 so not sure if the above is the same for beta 2.

Cheers,

Jason


I made a very simple test to try out UpdateProgress in Beta 2.

There'a a Master Page with a ScriptManager on it.

A Content Page that looks like this

<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate>   <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" /> </Triggers> </asp:UpdatePanel> <br /> <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1" DynamicLayout="False"> <ProgressTemplate>loading...</ProgressTemplate> </asp:UpdateProgress> <br />   <asp:UpdatePanel ID="UpdatePanel2" runat="server"> <ContentTemplate>  <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Button" /> <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label> </ContentTemplate> </asp:UpdatePanel> <asp:UpdateProgress ID="UpdateProgress2" runat="server" AssociatedUpdatePanelID="UpdatePanel2" DynamicLayout="False"> <ProgressTemplate>loading...</ProgressTemplate> </asp:UpdateProgress>
Code is:
 
protected static int i = 0;protected void Page_Load(object sender, EventArgs e) { }protected void Button1_Click(object sender, EventArgs e) { Label1.Text = DateTime.Now.ToLongTimeString(); System.Threading.Thread.CurrentThread.Join(1000); }protected void Button2_Click(object sender, EventArgs e) { i++; Label2.Text = i.ToString(); System.Threading.Thread.CurrentThread.Join(1000); }

It's just two buttons and two labels. The first one displays the date, the second one increases a counter. Both have an UpdatePanel and UpdateProgress. The first UpdatePanel has a trigger event, which is the Button1's click. The second UpdatePanel has both the Button2 and Label2 inside it.

The first UpdateProgress does NOT work. The second one does. I didn't have to use ClientID or Unique ID, even though I'm using Master Pages. The problem, as far as I can see, is when the UpdatePanel has a trigger.


That still does not work for me - using beta 2. I have a page (that uses a masterpage), with two web user controls, each with their own updatepanel and updateprogress controls. when i try to specify the AssociatedUpdatePanelID in either user control in the Page_Load i get the following error:

No UpdatePanel found for AssociatedUpdatePanelID 'ctl00_ContentPlaceHolder1_Weather1_WeatherUpdatePanel'

I also tried to just create a simple page (w/o using a masterpage) with 2 updatepanels, 2 updateprogress controls and 2 buttons. when i specify the AssociatedUpdatePanelID in Page_Load on this page, there is no error message, but neither UpdateProgress control is never displayed either. If I don't specify the AssociatedUpdatePanelID, then both UpdateProgress controls appear.

If anyone else has any thoughts, I'd appreciate it. I can also post code, if desired.

Thanks

No comments:

Post a Comment